<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vite + React + TS</title>
    <script type="module" crossorigin>(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();var pd={exports:{}},Rs={};/**
 * @license React
 * react-jsx-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Hg;function kk(){if(Hg)return Rs;Hg=1;var a=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,o,l){var u=null;if(l!==void 0&&(u=""+l),o.key!==void 0&&(u=""+o.key),"key"in o){l={};for(var d in o)d!=="key"&&(l[d]=o[d])}else l=o;return o=l.ref,{$$typeof:a,type:r,key:u,ref:o!==void 0?o:null,props:l}}return Rs.Fragment=e,Rs.jsx=n,Rs.jsxs=n,Rs}var Gg;function Ck(){return Gg||(Gg=1,pd.exports=kk()),pd.exports}var Ne=Ck(),gd={exports:{}},pe={};/**
 * @license React
 * react.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Fg;function Ek(){if(Fg)return pe;Fg=1;var a=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),y=Symbol.iterator;function b(D){return D===null||typeof D!="object"?null:(D=y&&D[y]||D["@@iterator"],typeof D=="function"?D:null)}var T={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,k={};function w(D,Z,fe){this.props=D,this.context=Z,this.refs=k,this.updater=fe||T}w.prototype.isReactComponent={},w.prototype.setState=function(D,Z){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,Z,"setState")},w.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function O(){}O.prototype=w.prototype;function V(D,Z,fe){this.props=D,this.context=Z,this.refs=k,this.updater=fe||T}var Q=V.prototype=new O;Q.constructor=V,C(Q,w.prototype),Q.isPureReactComponent=!0;var U=Array.isArray,_={H:null,A:null,T:null,S:null},H=Object.prototype.hasOwnProperty;function $(D,Z,fe,le,ae,Ce){return fe=Ce.ref,{$$typeof:a,type:D,key:Z,ref:fe!==void 0?fe:null,props:Ce}}function ie(D,Z){return $(D.type,Z,void 0,void 0,void 0,D.props)}function X(D){return typeof D=="object"&&D!==null&&D.$$typeof===a}function J(D){var Z={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(fe){return Z[fe]})}var ee=/\/+/g;function oe(D,Z){return typeof D=="object"&&D!==null&&D.key!=null?J(""+D.key):Z.toString(36)}function qe(){}function Fe(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(qe,qe):(D.status="pending",D.then(function(Z){D.status==="pending"&&(D.status="fulfilled",D.value=Z)},function(Z){D.status==="pending"&&(D.status="rejected",D.reason=Z)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function Ye(D,Z,fe,le,ae){var Ce=typeof D;(Ce==="undefined"||Ce==="boolean")&&(D=null);var ge=!1;if(D===null)ge=!0;else switch(Ce){case"bigint":case"string":case"number":ge=!0;break;case"object":switch(D.$$typeof){case a:case e:ge=!0;break;case g:return ge=D._init,Ye(ge(D._payload),Z,fe,le,ae)}}if(ge)return ae=ae(D),ge=le===""?"."+oe(D,0):le,U(ae)?(fe="",ge!=null&&(fe=ge.replace(ee,"$&/")+"/"),Ye(ae,Z,fe,"",function(it){return it})):ae!=null&&(X(ae)&&(ae=ie(ae,fe+(ae.key==null||D&&D.key===ae.key?"":(""+ae.key).replace(ee,"$&/")+"/")+ge)),Z.push(ae)),1;ge=0;var Rt=le===""?".":le+":";if(U(D))for(var De=0;De<D.length;De++)le=D[De],Ce=Rt+oe(le,De),ge+=Ye(le,Z,fe,Ce,ae);else if(De=b(D),typeof De=="function")for(D=De.call(D),De=0;!(le=D.next()).done;)le=le.value,Ce=Rt+oe(le,De++),ge+=Ye(le,Z,fe,Ce,ae);else if(Ce==="object"){if(typeof D.then=="function")return Ye(Fe(D),Z,fe,le,ae);throw Z=String(D),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.")}return ge}function te(D,Z,fe){if(D==null)return D;var le=[],ae=0;return Ye(D,le,"","",function(Ce){return Z.call(fe,Ce,ae++)}),le}function he(D){if(D._status===-1){var Z=D._result;Z=Z(),Z.then(function(fe){(D._status===0||D._status===-1)&&(D._status=1,D._result=fe)},function(fe){(D._status===0||D._status===-1)&&(D._status=2,D._result=fe)}),D._status===-1&&(D._status=0,D._result=Z)}if(D._status===1)return D._result.default;throw D._result}var ue=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(Z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)};function je(){}return pe.Children={map:te,forEach:function(D,Z,fe){te(D,function(){Z.apply(this,arguments)},fe)},count:function(D){var Z=0;return te(D,function(){Z++}),Z},toArray:function(D){return te(D,function(Z){return Z})||[]},only:function(D){if(!X(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},pe.Component=w,pe.Fragment=n,pe.Profiler=o,pe.PureComponent=V,pe.StrictMode=r,pe.Suspense=h,pe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=_,pe.act=function(){throw Error("act(...) is not supported in production builds of React.")},pe.cache=function(D){return function(){return D.apply(null,arguments)}},pe.cloneElement=function(D,Z,fe){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var le=C({},D.props),ae=D.key,Ce=void 0;if(Z!=null)for(ge in Z.ref!==void 0&&(Ce=void 0),Z.key!==void 0&&(ae=""+Z.key),Z)!H.call(Z,ge)||ge==="key"||ge==="__self"||ge==="__source"||ge==="ref"&&Z.ref===void 0||(le[ge]=Z[ge]);var ge=arguments.length-2;if(ge===1)le.children=fe;else if(1<ge){for(var Rt=Array(ge),De=0;De<ge;De++)Rt[De]=arguments[De+2];le.children=Rt}return $(D.type,ae,void 0,void 0,Ce,le)},pe.createContext=function(D){return D={$$typeof:u,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:l,_context:D},D},pe.createElement=function(D,Z,fe){var le,ae={},Ce=null;if(Z!=null)for(le in Z.key!==void 0&&(Ce=""+Z.key),Z)H.call(Z,le)&&le!=="key"&&le!=="__self"&&le!=="__source"&&(ae[le]=Z[le]);var ge=arguments.length-2;if(ge===1)ae.children=fe;else if(1<ge){for(var Rt=Array(ge),De=0;De<ge;De++)Rt[De]=arguments[De+2];ae.children=Rt}if(D&&D.defaultProps)for(le in ge=D.defaultProps,ge)ae[le]===void 0&&(ae[le]=ge[le]);return $(D,Ce,void 0,void 0,null,ae)},pe.createRef=function(){return{current:null}},pe.forwardRef=function(D){return{$$typeof:d,render:D}},pe.isValidElement=X,pe.lazy=function(D){return{$$typeof:g,_payload:{_status:-1,_result:D},_init:he}},pe.memo=function(D,Z){return{$$typeof:m,type:D,compare:Z===void 0?null:Z}},pe.startTransition=function(D){var Z=_.T,fe={};_.T=fe;try{var le=D(),ae=_.S;ae!==null&&ae(fe,le),typeof le=="object"&&le!==null&&typeof le.then=="function"&&le.then(je,ue)}catch(Ce){ue(Ce)}finally{_.T=Z}},pe.unstable_useCacheRefresh=function(){return _.H.useCacheRefresh()},pe.use=function(D){return _.H.use(D)},pe.useActionState=function(D,Z,fe){return _.H.useActionState(D,Z,fe)},pe.useCallback=function(D,Z){return _.H.useCallback(D,Z)},pe.useContext=function(D){return _.H.useContext(D)},pe.useDebugValue=function(){},pe.useDeferredValue=function(D,Z){return _.H.useDeferredValue(D,Z)},pe.useEffect=function(D,Z){return _.H.useEffect(D,Z)},pe.useId=function(){return _.H.useId()},pe.useImperativeHandle=function(D,Z,fe){return _.H.useImperativeHandle(D,Z,fe)},pe.useInsertionEffect=function(D,Z){return _.H.useInsertionEffect(D,Z)},pe.useLayoutEffect=function(D,Z){return _.H.useLayoutEffect(D,Z)},pe.useMemo=function(D,Z){return _.H.useMemo(D,Z)},pe.useOptimistic=function(D,Z){return _.H.useOptimistic(D,Z)},pe.useReducer=function(D,Z,fe){return _.H.useReducer(D,Z,fe)},pe.useRef=function(D){return _.H.useRef(D)},pe.useState=function(D){return _.H.useState(D)},pe.useSyncExternalStore=function(D,Z,fe){return _.H.useSyncExternalStore(D,Z,fe)},pe.useTransition=function(){return _.H.useTransition()},pe.version="19.0.0",pe}var Yg;function Mf(){return Yg||(Yg=1,gd.exports=Ek()),gd.exports}var P=Mf(),vd={exports:{}},_s={},yd={exports:{}},bd={};/**
 * @license React
 * scheduler.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Kg;function Rk(){return Kg||(Kg=1,function(a){function e(te,he){var ue=te.length;te.push(he);e:for(;0<ue;){var je=ue-1>>>1,D=te[je];if(0<o(D,he))te[je]=he,te[ue]=D,ue=je;else break e}}function n(te){return te.length===0?null:te[0]}function r(te){if(te.length===0)return null;var he=te[0],ue=te.pop();if(ue!==he){te[0]=ue;e:for(var je=0,D=te.length,Z=D>>>1;je<Z;){var fe=2*(je+1)-1,le=te[fe],ae=fe+1,Ce=te[ae];if(0>o(le,ue))ae<D&&0>o(Ce,le)?(te[je]=Ce,te[ae]=ue,je=ae):(te[je]=le,te[fe]=ue,je=fe);else if(ae<D&&0>o(Ce,ue))te[je]=Ce,te[ae]=ue,je=ae;else break e}}return he}function o(te,he){var ue=te.sortIndex-he.sortIndex;return ue!==0?ue:te.id-he.id}if(a.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;a.unstable_now=function(){return l.now()}}else{var u=Date,d=u.now();a.unstable_now=function(){return u.now()-d}}var h=[],m=[],g=1,y=null,b=3,T=!1,C=!1,k=!1,w=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,V=typeof setImmediate<"u"?setImmediate:null;function Q(te){for(var he=n(m);he!==null;){if(he.callback===null)r(m);else if(he.startTime<=te)r(m),he.sortIndex=he.expirationTime,e(h,he);else break;he=n(m)}}function U(te){if(k=!1,Q(te),!C)if(n(h)!==null)C=!0,Fe();else{var he=n(m);he!==null&&Ye(U,he.startTime-te)}}var _=!1,H=-1,$=5,ie=-1;function X(){return!(a.unstable_now()-ie<$)}function J(){if(_){var te=a.unstable_now();ie=te;var he=!0;try{e:{C=!1,k&&(k=!1,O(H),H=-1),T=!0;var ue=b;try{t:{for(Q(te),y=n(h);y!==null&&!(y.expirationTime>te&&X());){var je=y.callback;if(typeof je=="function"){y.callback=null,b=y.priorityLevel;var D=je(y.expirationTime<=te);if(te=a.unstable_now(),typeof D=="function"){y.callback=D,Q(te),he=!0;break t}y===n(h)&&r(h),Q(te)}else r(h);y=n(h)}if(y!==null)he=!0;else{var Z=n(m);Z!==null&&Ye(U,Z.startTime-te),he=!1}}break e}finally{y=null,b=ue,T=!1}he=void 0}}finally{he?ee():_=!1}}}var ee;if(typeof V=="function")ee=function(){V(J)};else if(typeof MessageChannel<"u"){var oe=new MessageChannel,qe=oe.port2;oe.port1.onmessage=J,ee=function(){qe.postMessage(null)}}else ee=function(){w(J,0)};function Fe(){_||(_=!0,ee())}function Ye(te,he){H=w(function(){te(a.unstable_now())},he)}a.unstable_IdlePriority=5,a.unstable_ImmediatePriority=1,a.unstable_LowPriority=4,a.unstable_NormalPriority=3,a.unstable_Profiling=null,a.unstable_UserBlockingPriority=2,a.unstable_cancelCallback=function(te){te.callback=null},a.unstable_continueExecution=function(){C||T||(C=!0,Fe())},a.unstable_forceFrameRate=function(te){0>te||125<te?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<te?Math.floor(1e3/te):5},a.unstable_getCurrentPriorityLevel=function(){return b},a.unstable_getFirstCallbackNode=function(){return n(h)},a.unstable_next=function(te){switch(b){case 1:case 2:case 3:var he=3;break;default:he=b}var ue=b;b=he;try{return te()}finally{b=ue}},a.unstable_pauseExecution=function(){},a.unstable_requestPaint=function(){},a.unstable_runWithPriority=function(te,he){switch(te){case 1:case 2:case 3:case 4:case 5:break;default:te=3}var ue=b;b=te;try{return he()}finally{b=ue}},a.unstable_scheduleCallback=function(te,he,ue){var je=a.unstable_now();switch(typeof ue=="object"&&ue!==null?(ue=ue.delay,ue=typeof ue=="number"&&0<ue?je+ue:je):ue=je,te){case 1:var D=-1;break;case 2:D=250;break;case 5:D=1073741823;break;case 4:D=1e4;break;default:D=5e3}return D=ue+D,te={id:g++,callback:he,priorityLevel:te,startTime:ue,expirationTime:D,sortIndex:-1},ue>je?(te.sortIndex=ue,e(m,te),n(h)===null&&te===n(m)&&(k?(O(H),H=-1):k=!0,Ye(U,ue-je))):(te.sortIndex=D,e(h,te),C||T||(C=!0,Fe())),te},a.unstable_shouldYield=X,a.unstable_wrapCallback=function(te){var he=b;return function(){var ue=b;b=he;try{return te.apply(this,arguments)}finally{b=ue}}}}(bd)),bd}var Qg;function _k(){return Qg||(Qg=1,yd.exports=Rk()),yd.exports}var Sd={exports:{}},Et={};/**
 * @license React
 * react-dom.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Xg;function wk(){if(Xg)return Et;Xg=1;var a=Mf();function e(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var g=2;g<arguments.length;g++)m+="&args[]="+encodeURIComponent(arguments[g])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function l(h,m,g){var y=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:y==null?null:""+y,children:h,containerInfo:m,implementation:g}}var u=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(h,m){if(h==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return Et.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Et.createPortal=function(h,m){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(e(299));return l(h,m,null,g)},Et.flushSync=function(h){var m=u.T,g=r.p;try{if(u.T=null,r.p=2,h)return h()}finally{u.T=m,r.p=g,r.d.f()}},Et.preconnect=function(h,m){typeof h=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,r.d.C(h,m))},Et.prefetchDNS=function(h){typeof h=="string"&&r.d.D(h)},Et.preinit=function(h,m){if(typeof h=="string"&&m&&typeof m.as=="string"){var g=m.as,y=d(g,m.crossOrigin),b=typeof m.integrity=="string"?m.integrity:void 0,T=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;g==="style"?r.d.S(h,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:y,integrity:b,fetchPriority:T}):g==="script"&&r.d.X(h,{crossOrigin:y,integrity:b,fetchPriority:T,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},Et.preinitModule=function(h,m){if(typeof h=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var g=d(m.as,m.crossOrigin);r.d.M(h,{crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&r.d.M(h)},Et.preload=function(h,m){if(typeof h=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var g=m.as,y=d(g,m.crossOrigin);r.d.L(h,g,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},Et.preloadModule=function(h,m){if(typeof h=="string")if(m){var g=d(m.as,m.crossOrigin);r.d.m(h,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:g,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else r.d.m(h)},Et.requestFormReset=function(h){r.d.r(h)},Et.unstable_batchedUpdates=function(h,m){return h(m)},Et.useFormState=function(h,m,g){return u.H.useFormState(h,m,g)},Et.useFormStatus=function(){return u.H.useHostTransitionStatus()},Et.version="19.0.0",Et}var Zg;function Ok(){if(Zg)return Sd.exports;Zg=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(e){console.error(e)}}return a(),Sd.exports=wk(),Sd.exports}/**
 * @license React
 * react-dom-client.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Jg;function Dk(){if(Jg)return _s;Jg=1;var a=_k(),e=Mf(),n=Ok();function r(t){var i="https://react.dev/errors/"+t;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)i+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+t+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}var l=Symbol.for("react.element"),u=Symbol.for("react.transitional.element"),d=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),b=Symbol.for("react.consumer"),T=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),Q=Symbol.for("react.offscreen"),U=Symbol.for("react.memo_cache_sentinel"),_=Symbol.iterator;function H(t){return t===null||typeof t!="object"?null:(t=_&&t[_]||t["@@iterator"],typeof t=="function"?t:null)}var $=Symbol.for("react.client.reference");function ie(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===$?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case h:return"Fragment";case d:return"Portal";case g:return"Profiler";case m:return"StrictMode";case k:return"Suspense";case w:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case T:return(t.displayName||"Context")+".Provider";case b:return(t._context.displayName||"Context")+".Consumer";case C:var i=t.render;return t=t.displayName,t||(t=i.displayName||i.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case O:return i=t.displayName||null,i!==null?i:ie(t.type)||"Memo";case V:i=t._payload,t=t._init;try{return ie(t(i))}catch{}}return null}var X=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=Object.assign,ee,oe;function qe(t){if(ee===void 0)try{throw Error()}catch(s){var i=s.stack.trim().match(/\n( *(at )?)/);ee=i&&i[1]||"",oe=-1<s.stack.indexOf(`
    at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
`+ee+t+oe}var Fe=!1;function Ye(t,i){if(!t||Fe)return"";Fe=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var c={DetermineComponentFrameRoot:function(){try{if(i){var K=function(){throw Error()};if(Object.defineProperty(K.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(K,[])}catch(z){var L=z}Reflect.construct(t,[],K)}else{try{K.call()}catch(z){L=z}t.call(K.prototype)}}else{try{throw Error()}catch(z){L=z}(K=t())&&typeof K.catch=="function"&&K.catch(function(){})}}catch(z){if(z&&L&&typeof z.stack=="string")return[z.stack,L.stack]}return[null,null]}};c.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(c.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(c.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var p=c.DetermineComponentFrameRoot(),v=p[0],S=p[1];if(v&&S){var E=v.split(`
`),M=S.split(`
`);for(f=c=0;c<E.length&&!E[c].includes("DetermineComponentFrameRoot");)c++;for(;f<M.length&&!M[f].includes("DetermineComponentFrameRoot");)f++;if(c===E.length||f===M.length)for(c=E.length-1,f=M.length-1;1<=c&&0<=f&&E[c]!==M[f];)f--;for(;1<=c&&0<=f;c--,f--)if(E[c]!==M[f]){if(c!==1||f!==1)do if(c--,f--,0>f||E[c]!==M[f]){var q=`
`+E[c].replace(" at new "," at ");return t.displayName&&q.includes("<anonymous>")&&(q=q.replace("<anonymous>",t.displayName)),q}while(1<=c&&0<=f);break}}}finally{Fe=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?qe(s):""}function te(t){switch(t.tag){case 26:case 27:case 5:return qe(t.type);case 16:return qe("Lazy");case 13:return qe("Suspense");case 19:return qe("SuspenseList");case 0:case 15:return t=Ye(t.type,!1),t;case 11:return t=Ye(t.type.render,!1),t;case 1:return t=Ye(t.type,!0),t;default:return""}}function he(t){try{var i="";do i+=te(t),t=t.return;while(t);return i}catch(s){return`
Error generating stack: `+s.message+`
`+s.stack}}function ue(t){var i=t,s=t;if(t.alternate)for(;i.return;)i=i.return;else{t=i;do i=t,(i.flags&4098)!==0&&(s=i.return),t=i.return;while(t)}return i.tag===3?s:null}function je(t){if(t.tag===13){var i=t.memoizedState;if(i===null&&(t=t.alternate,t!==null&&(i=t.memoizedState)),i!==null)return i.dehydrated}return null}function D(t){if(ue(t)!==t)throw Error(r(188))}function Z(t){var i=t.alternate;if(!i){if(i=ue(t),i===null)throw Error(r(188));return i!==t?null:t}for(var s=t,c=i;;){var f=s.return;if(f===null)break;var p=f.alternate;if(p===null){if(c=f.return,c!==null){s=c;continue}break}if(f.child===p.child){for(p=f.child;p;){if(p===s)return D(f),t;if(p===c)return D(f),i;p=p.sibling}throw Error(r(188))}if(s.return!==c.return)s=f,c=p;else{for(var v=!1,S=f.child;S;){if(S===s){v=!0,s=f,c=p;break}if(S===c){v=!0,c=f,s=p;break}S=S.sibling}if(!v){for(S=p.child;S;){if(S===s){v=!0,s=p,c=f;break}if(S===c){v=!0,c=p,s=f;break}S=S.sibling}if(!v)throw Error(r(189))}}if(s.alternate!==c)throw Error(r(190))}if(s.tag!==3)throw Error(r(188));return s.stateNode.current===s?t:i}function fe(t){var i=t.tag;if(i===5||i===26||i===27||i===6)return t;for(t=t.child;t!==null;){if(i=fe(t),i!==null)return i;t=t.sibling}return null}var le=Array.isArray,ae=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Ce={pending:!1,data:null,method:null,action:null},ge=[],Rt=-1;function De(t){return{current:t}}function it(t){0>Rt||(t.current=ge[Rt],ge[Rt]=null,Rt--)}function Ve(t,i){Rt++,ge[Rt]=t.current,t.current=i}var bn=De(null),Or=De(null),ri=De(null),Xs=De(null);function Zs(t,i){switch(Ve(ri,i),Ve(Or,t),Ve(bn,null),t=i.nodeType,t){case 9:case 11:i=(i=i.documentElement)&&(i=i.namespaceURI)?yg(i):0;break;default:if(t=t===8?i.parentNode:i,i=t.tagName,t=t.namespaceURI)t=yg(t),i=bg(t,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}it(bn),Ve(bn,i)}function Ca(){it(bn),it(Or),it(ri)}function sl(t){t.memoizedState!==null&&Ve(Xs,t);var i=bn.current,s=bg(i,t.type);i!==s&&(Ve(Or,t),Ve(bn,s))}function Js(t){Or.current===t&&(it(bn),it(Or)),Xs.current===t&&(it(Xs),Ss._currentValue=Ce)}var ol=Object.prototype.hasOwnProperty,cl=a.unstable_scheduleCallback,ll=a.unstable_cancelCallback,eS=a.unstable_shouldYield,tS=a.unstable_requestPaint,Sn=a.unstable_now,nS=a.unstable_getCurrentPriorityLevel,oh=a.unstable_ImmediatePriority,ch=a.unstable_UserBlockingPriority,Ws=a.unstable_NormalPriority,iS=a.unstable_LowPriority,lh=a.unstable_IdlePriority,aS=a.log,rS=a.unstable_setDisableYieldValue,Dr=null,Ut=null;function sS(t){if(Ut&&typeof Ut.onCommitFiberRoot=="function")try{Ut.onCommitFiberRoot(Dr,t,void 0,(t.current.flags&128)===128)}catch{}}function si(t){if(typeof aS=="function"&&rS(t),Ut&&typeof Ut.setStrictMode=="function")try{Ut.setStrictMode(Dr,t)}catch{}}var Lt=Math.clz32?Math.clz32:lS,oS=Math.log,cS=Math.LN2;function lS(t){return t>>>=0,t===0?32:31-(oS(t)/cS|0)|0}var $s=128,eo=4194304;function Gi(t){var i=t&42;if(i!==0)return i;switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194176;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function to(t,i){var s=t.pendingLanes;if(s===0)return 0;var c=0,f=t.suspendedLanes,p=t.pingedLanes,v=t.warmLanes;t=t.finishedLanes!==0;var S=s&134217727;return S!==0?(s=S&~f,s!==0?c=Gi(s):(p&=S,p!==0?c=Gi(p):t||(v=S&~v,v!==0&&(c=Gi(v))))):(S=s&~f,S!==0?c=Gi(S):p!==0?c=Gi(p):t||(v=s&~v,v!==0&&(c=Gi(v)))),c===0?0:i!==0&&i!==c&&(i&f)===0&&(f=c&-c,v=i&-i,f>=v||f===32&&(v&4194176)!==0)?i:c}function Ar(t,i){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&i)===0}function uS(t,i){switch(t){case 1:case 2:case 4:case 8:return i+250;case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function uh(){var t=$s;return $s<<=1,($s&4194176)===0&&($s=128),t}function dh(){var t=eo;return eo<<=1,(eo&62914560)===0&&(eo=4194304),t}function ul(t){for(var i=[],s=0;31>s;s++)i.push(t);return i}function Mr(t,i){t.pendingLanes|=i,i!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function dS(t,i,s,c,f,p){var v=t.pendingLanes;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=s,t.entangledLanes&=s,t.errorRecoveryDisabledLanes&=s,t.shellSuspendCounter=0;var S=t.entanglements,E=t.expirationTimes,M=t.hiddenUpdates;for(s=v&~s;0<s;){var q=31-Lt(s),K=1<<q;S[q]=0,E[q]=-1;var L=M[q];if(L!==null)for(M[q]=null,q=0;q<L.length;q++){var z=L[q];z!==null&&(z.lane&=-536870913)}s&=~K}c!==0&&fh(t,c,0),p!==0&&f===0&&t.tag!==0&&(t.suspendedLanes|=p&~(v&~i))}function fh(t,i,s){t.pendingLanes|=i,t.suspendedLanes&=~i;var c=31-Lt(i);t.entangledLanes|=i,t.entanglements[c]=t.entanglements[c]|1073741824|s&4194218}function hh(t,i){var s=t.entangledLanes|=i;for(t=t.entanglements;s;){var c=31-Lt(s),f=1<<c;f&i|t[c]&i&&(t[c]|=i),s&=~f}}function mh(t){return t&=-t,2<t?8<t?(t&134217727)!==0?32:268435456:8:2}function ph(){var t=ae.p;return t!==0?t:(t=window.event,t===void 0?32:Ig(t.type))}function fS(t,i){var s=ae.p;try{return ae.p=t,i()}finally{ae.p=s}}var oi=Math.random().toString(36).slice(2),kt="__reactFiber$"+oi,Ot="__reactProps$"+oi,Ea="__reactContainer$"+oi,dl="__reactEvents$"+oi,hS="__reactListeners$"+oi,mS="__reactHandles$"+oi,gh="__reactResources$"+oi,Pr="__reactMarker$"+oi;function fl(t){delete t[kt],delete t[Ot],delete t[dl],delete t[hS],delete t[mS]}function Fi(t){var i=t[kt];if(i)return i;for(var s=t.parentNode;s;){if(i=s[Ea]||s[kt]){if(s=i.alternate,i.child!==null||s!==null&&s.child!==null)for(t=kg(t);t!==null;){if(s=t[kt])return s;t=kg(t)}return i}t=s,s=t.parentNode}return null}function Ra(t){if(t=t[kt]||t[Ea]){var i=t.tag;if(i===5||i===6||i===13||i===26||i===27||i===3)return t}return null}function xr(t){var i=t.tag;if(i===5||i===26||i===27||i===6)return t.stateNode;throw Error(r(33))}function _a(t){var i=t[gh];return i||(i=t[gh]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function ft(t){t[Pr]=!0}var vh=new Set,yh={};function Yi(t,i){wa(t,i),wa(t+"Capture",i)}function wa(t,i){for(yh[t]=i,t=0;t<i.length;t++)vh.add(i[t])}var Un=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),pS=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),bh={},Sh={};function gS(t){return ol.call(Sh,t)?!0:ol.call(bh,t)?!1:pS.test(t)?Sh[t]=!0:(bh[t]=!0,!1)}function no(t,i,s){if(gS(i))if(s===null)t.removeAttribute(i);else{switch(typeof s){case"undefined":case"function":case"symbol":t.removeAttribute(i);return;case"boolean":var c=i.toLowerCase().slice(0,5);if(c!=="data-"&&c!=="aria-"){t.removeAttribute(i);return}}t.setAttribute(i,""+s)}}function io(t,i,s){if(s===null)t.removeAttribute(i);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(i);return}t.setAttribute(i,""+s)}}function Ln(t,i,s,c){if(c===null)t.removeAttribute(s);else{switch(typeof c){case"undefined":case"function":case"symbol":case"boolean":t.removeAttribute(s);return}t.setAttributeNS(i,s,""+c)}}function Yt(t){switch(typeof t){case"bigint":case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Th(t){var i=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function vS(t){var i=Th(t)?"checked":"value",s=Object.getOwnPropertyDescriptor(t.constructor.prototype,i),c=""+t[i];if(!t.hasOwnProperty(i)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var f=s.get,p=s.set;return Object.defineProperty(t,i,{configurable:!0,get:function(){return f.call(this)},set:function(v){c=""+v,p.call(this,v)}}),Object.defineProperty(t,i,{enumerable:s.enumerable}),{getValue:function(){return c},setValue:function(v){c=""+v},stopTracking:function(){t._valueTracker=null,delete t[i]}}}}function ao(t){t._valueTracker||(t._valueTracker=vS(t))}function kh(t){if(!t)return!1;var i=t._valueTracker;if(!i)return!0;var s=i.getValue(),c="";return t&&(c=Th(t)?t.checked?"true":"false":t.value),t=c,t!==s?(i.setValue(t),!0):!1}function ro(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var yS=/[\n"\\]/g;function Kt(t){return t.replace(yS,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function hl(t,i,s,c,f,p,v,S){t.name="",v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"?t.type=v:t.removeAttribute("type"),i!=null?v==="number"?(i===0&&t.value===""||t.value!=i)&&(t.value=""+Yt(i)):t.value!==""+Yt(i)&&(t.value=""+Yt(i)):v!=="submit"&&v!=="reset"||t.removeAttribute("value"),i!=null?ml(t,v,Yt(i)):s!=null?ml(t,v,Yt(s)):c!=null&&t.removeAttribute("value"),f==null&&p!=null&&(t.defaultChecked=!!p),f!=null&&(t.checked=f&&typeof f!="function"&&typeof f!="symbol"),S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?t.name=""+Yt(S):t.removeAttribute("name")}function Ch(t,i,s,c,f,p,v,S){if(p!=null&&typeof p!="function"&&typeof p!="symbol"&&typeof p!="boolean"&&(t.type=p),i!=null||s!=null){if(!(p!=="submit"&&p!=="reset"||i!=null))return;s=s!=null?""+Yt(s):"",i=i!=null?""+Yt(i):s,S||i===t.value||(t.value=i),t.defaultValue=i}c=c??f,c=typeof c!="function"&&typeof c!="symbol"&&!!c,t.checked=S?t.checked:!!c,t.defaultChecked=!!c,v!=null&&typeof v!="function"&&typeof v!="symbol"&&typeof v!="boolean"&&(t.name=v)}function ml(t,i,s){i==="number"&&ro(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function Oa(t,i,s,c){if(t=t.options,i){i={};for(var f=0;f<s.length;f++)i["$"+s[f]]=!0;for(s=0;s<t.length;s++)f=i.hasOwnProperty("$"+t[s].value),t[s].selected!==f&&(t[s].selected=f),f&&c&&(t[s].defaultSelected=!0)}else{for(s=""+Yt(s),i=null,f=0;f<t.length;f++){if(t[f].value===s){t[f].selected=!0,c&&(t[f].defaultSelected=!0);return}i!==null||t[f].disabled||(i=t[f])}i!==null&&(i.selected=!0)}}function Eh(t,i,s){if(i!=null&&(i=""+Yt(i),i!==t.value&&(t.value=i),s==null)){t.defaultValue!==i&&(t.defaultValue=i);return}t.defaultValue=s!=null?""+Yt(s):""}function Rh(t,i,s,c){if(i==null){if(c!=null){if(s!=null)throw Error(r(92));if(le(c)){if(1<c.length)throw Error(r(93));c=c[0]}s=c}s==null&&(s=""),i=s}s=Yt(i),t.defaultValue=s,c=t.textContent,c===s&&c!==""&&c!==null&&(t.value=c)}function Da(t,i){if(i){var s=t.firstChild;if(s&&s===t.lastChild&&s.nodeType===3){s.nodeValue=i;return}}t.textContent=i}var bS=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function _h(t,i,s){var c=i.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?c?t.setProperty(i,""):i==="float"?t.cssFloat="":t[i]="":c?t.setProperty(i,s):typeof s!="number"||s===0||bS.has(i)?i==="float"?t.cssFloat=s:t[i]=(""+s).trim():t[i]=s+"px"}function wh(t,i,s){if(i!=null&&typeof i!="object")throw Error(r(62));if(t=t.style,s!=null){for(var c in s)!s.hasOwnProperty(c)||i!=null&&i.hasOwnProperty(c)||(c.indexOf("--")===0?t.setProperty(c,""):c==="float"?t.cssFloat="":t[c]="");for(var f in i)c=i[f],i.hasOwnProperty(f)&&s[f]!==c&&_h(t,f,c)}else for(var p in i)i.hasOwnProperty(p)&&_h(t,p,i[p])}function pl(t){if(t.indexOf("-")===-1)return!1;switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var SS=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),TS=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function so(t){return TS.test(""+t)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":t}var gl=null;function vl(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Aa=null,Ma=null;function Oh(t){var i=Ra(t);if(i&&(t=i.stateNode)){var s=t[Ot]||null;e:switch(t=i.stateNode,i.type){case"input":if(hl(t,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),i=s.name,s.type==="radio"&&i!=null){for(s=t;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+Kt(""+i)+'"][type="radio"]'),i=0;i<s.length;i++){var c=s[i];if(c!==t&&c.form===t.form){var f=c[Ot]||null;if(!f)throw Error(r(90));hl(c,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(i=0;i<s.length;i++)c=s[i],c.form===t.form&&kh(c)}break e;case"textarea":Eh(t,s.value,s.defaultValue);break e;case"select":i=s.value,i!=null&&Oa(t,!!s.multiple,i,!1)}}}var yl=!1;function Dh(t,i,s){if(yl)return t(i,s);yl=!0;try{var c=t(i);return c}finally{if(yl=!1,(Aa!==null||Ma!==null)&&(Go(),Aa&&(i=Aa,t=Ma,Ma=Aa=null,Oh(i),t)))for(i=0;i<t.length;i++)Oh(t[i])}}function Nr(t,i){var s=t.stateNode;if(s===null)return null;var c=s[Ot]||null;if(c===null)return null;s=c[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(c=!c.disabled)||(t=t.type,c=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!c;break e;default:t=!1}if(t)return null;if(s&&typeof s!="function")throw Error(r(231,i,typeof s));return s}var bl=!1;if(Un)try{var Ur={};Object.defineProperty(Ur,"passive",{get:function(){bl=!0}}),window.addEventListener("test",Ur,Ur),window.removeEventListener("test",Ur,Ur)}catch{bl=!1}var ci=null,Sl=null,oo=null;function Ah(){if(oo)return oo;var t,i=Sl,s=i.length,c,f="value"in ci?ci.value:ci.textContent,p=f.length;for(t=0;t<s&&i[t]===f[t];t++);var v=s-t;for(c=1;c<=v&&i[s-c]===f[p-c];c++);return oo=f.slice(t,1<c?1-c:void 0)}function co(t){var i=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&i===13&&(t=13)):t=i,t===10&&(t=13),32<=t||t===13?t:0}function lo(){return!0}function Mh(){return!1}function Dt(t){function i(s,c,f,p,v){this._reactName=s,this._targetInst=f,this.type=c,this.nativeEvent=p,this.target=v,this.currentTarget=null;for(var S in t)t.hasOwnProperty(S)&&(s=t[S],this[S]=s?s(p):p[S]);return this.isDefaultPrevented=(p.defaultPrevented!=null?p.defaultPrevented:p.returnValue===!1)?lo:Mh,this.isPropagationStopped=Mh,this}return J(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=lo)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=lo)},persist:function(){},isPersistent:lo}),i}var Ki={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},uo=Dt(Ki),Lr=J({},Ki,{view:0,detail:0}),kS=Dt(Lr),Tl,kl,Ir,fo=J({},Lr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:El,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Ir&&(Ir&&t.type==="mousemove"?(Tl=t.screenX-Ir.screenX,kl=t.screenY-Ir.screenY):kl=Tl=0,Ir=t),Tl)},movementY:function(t){return"movementY"in t?t.movementY:kl}}),Ph=Dt(fo),CS=J({},fo,{dataTransfer:0}),ES=Dt(CS),RS=J({},Lr,{relatedTarget:0}),Cl=Dt(RS),_S=J({},Ki,{animationName:0,elapsedTime:0,pseudoElement:0}),wS=Dt(_S),OS=J({},Ki,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),DS=Dt(OS),AS=J({},Ki,{data:0}),xh=Dt(AS),MS={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},PS={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},xS={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function NS(t){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(t):(t=xS[t])?!!i[t]:!1}function El(){return NS}var US=J({},Lr,{key:function(t){if(t.key){var i=MS[t.key]||t.key;if(i!=="Unidentified")return i}return t.type==="keypress"?(t=co(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?PS[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:El,charCode:function(t){return t.type==="keypress"?co(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?co(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),LS=Dt(US),IS=J({},fo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Nh=Dt(IS),jS=J({},Lr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:El}),BS=Dt(jS),zS=J({},Ki,{propertyName:0,elapsedTime:0,pseudoElement:0}),qS=Dt(zS),VS=J({},fo,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),HS=Dt(VS),GS=J({},Ki,{newState:0,oldState:0}),FS=Dt(GS),YS=[9,13,27,32],Rl=Un&&"CompositionEvent"in window,jr=null;Un&&"documentMode"in document&&(jr=document.documentMode);var KS=Un&&"TextEvent"in window&&!jr,Uh=Un&&(!Rl||jr&&8<jr&&11>=jr),Lh=" ",Ih=!1;function jh(t,i){switch(t){case"keyup":return YS.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bh(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Pa=!1;function QS(t,i){switch(t){case"compositionend":return Bh(i);case"keypress":return i.which!==32?null:(Ih=!0,Lh);case"textInput":return t=i.data,t===Lh&&Ih?null:t;default:return null}}function XS(t,i){if(Pa)return t==="compositionend"||!Rl&&jh(t,i)?(t=Ah(),oo=Sl=ci=null,Pa=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return Uh&&i.locale!=="ko"?null:i.data;default:return null}}var ZS={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function zh(t){var i=t&&t.nodeName&&t.nodeName.toLowerCase();return i==="input"?!!ZS[t.type]:i==="textarea"}function qh(t,i,s,c){Aa?Ma?Ma.push(c):Ma=[c]:Aa=c,i=Xo(i,"onChange"),0<i.length&&(s=new uo("onChange","change",null,s,c),t.push({event:s,listeners:i}))}var Br=null,zr=null;function JS(t){hg(t,0)}function ho(t){var i=xr(t);if(kh(i))return t}function Vh(t,i){if(t==="change")return i}var Hh=!1;if(Un){var _l;if(Un){var wl="oninput"in document;if(!wl){var Gh=document.createElement("div");Gh.setAttribute("oninput","return;"),wl=typeof Gh.oninput=="function"}_l=wl}else _l=!1;Hh=_l&&(!document.documentMode||9<document.documentMode)}function Fh(){Br&&(Br.detachEvent("onpropertychange",Yh),zr=Br=null)}function Yh(t){if(t.propertyName==="value"&&ho(zr)){var i=[];qh(i,zr,t,vl(t)),Dh(JS,i)}}function WS(t,i,s){t==="focusin"?(Fh(),Br=i,zr=s,Br.attachEvent("onpropertychange",Yh)):t==="focusout"&&Fh()}function $S(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return ho(zr)}function eT(t,i){if(t==="click")return ho(i)}function tT(t,i){if(t==="input"||t==="change")return ho(i)}function nT(t,i){return t===i&&(t!==0||1/t===1/i)||t!==t&&i!==i}var It=typeof Object.is=="function"?Object.is:nT;function qr(t,i){if(It(t,i))return!0;if(typeof t!="object"||t===null||typeof i!="object"||i===null)return!1;var s=Object.keys(t),c=Object.keys(i);if(s.length!==c.length)return!1;for(c=0;c<s.length;c++){var f=s[c];if(!ol.call(i,f)||!It(t[f],i[f]))return!1}return!0}function Kh(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Qh(t,i){var s=Kh(t);t=0;for(var c;s;){if(s.nodeType===3){if(c=t+s.textContent.length,t<=i&&c>=i)return{node:s,offset:i-t};t=c}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=Kh(s)}}function Xh(t,i){return t&&i?t===i?!0:t&&t.nodeType===3?!1:i&&i.nodeType===3?Xh(t,i.parentNode):"contains"in t?t.contains(i):t.compareDocumentPosition?!!(t.compareDocumentPosition(i)&16):!1:!1}function Zh(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var i=ro(t.document);i instanceof t.HTMLIFrameElement;){try{var s=typeof i.contentWindow.location.href=="string"}catch{s=!1}if(s)t=i.contentWindow;else break;i=ro(t.document)}return i}function Ol(t){var i=t&&t.nodeName&&t.nodeName.toLowerCase();return i&&(i==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||i==="textarea"||t.contentEditable==="true")}function iT(t,i){var s=Zh(i);i=t.focusedElem;var c=t.selectionRange;if(s!==i&&i&&i.ownerDocument&&Xh(i.ownerDocument.documentElement,i)){if(c!==null&&Ol(i)){if(t=c.start,s=c.end,s===void 0&&(s=t),"selectionStart"in i)i.selectionStart=t,i.selectionEnd=Math.min(s,i.value.length);else if(s=(t=i.ownerDocument||document)&&t.defaultView||window,s.getSelection){s=s.getSelection();var f=i.textContent.length,p=Math.min(c.start,f);c=c.end===void 0?p:Math.min(c.end,f),!s.extend&&p>c&&(f=c,c=p,p=f),f=Qh(i,p);var v=Qh(i,c);f&&v&&(s.rangeCount!==1||s.anchorNode!==f.node||s.anchorOffset!==f.offset||s.focusNode!==v.node||s.focusOffset!==v.offset)&&(t=t.createRange(),t.setStart(f.node,f.offset),s.removeAllRanges(),p>c?(s.addRange(t),s.extend(v.node,v.offset)):(t.setEnd(v.node,v.offset),s.addRange(t)))}}for(t=[],s=i;s=s.parentNode;)s.nodeType===1&&t.push({element:s,left:s.scrollLeft,top:s.scrollTop});for(typeof i.focus=="function"&&i.focus(),i=0;i<t.length;i++)s=t[i],s.element.scrollLeft=s.left,s.element.scrollTop=s.top}}var aT=Un&&"documentMode"in document&&11>=document.documentMode,xa=null,Dl=null,Vr=null,Al=!1;function Jh(t,i,s){var c=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Al||xa==null||xa!==ro(c)||(c=xa,"selectionStart"in c&&Ol(c)?c={start:c.selectionStart,end:c.selectionEnd}:(c=(c.ownerDocument&&c.ownerDocument.defaultView||window).getSelection(),c={anchorNode:c.anchorNode,anchorOffset:c.anchorOffset,focusNode:c.focusNode,focusOffset:c.focusOffset}),Vr&&qr(Vr,c)||(Vr=c,c=Xo(Dl,"onSelect"),0<c.length&&(i=new uo("onSelect","select",null,i,s),t.push({event:i,listeners:c}),i.target=xa)))}function Qi(t,i){var s={};return s[t.toLowerCase()]=i.toLowerCase(),s["Webkit"+t]="webkit"+i,s["Moz"+t]="moz"+i,s}var Na={animationend:Qi("Animation","AnimationEnd"),animationiteration:Qi("Animation","AnimationIteration"),animationstart:Qi("Animation","AnimationStart"),transitionrun:Qi("Transition","TransitionRun"),transitionstart:Qi("Transition","TransitionStart"),transitioncancel:Qi("Transition","TransitionCancel"),transitionend:Qi("Transition","TransitionEnd")},Ml={},Wh={};Un&&(Wh=document.createElement("div").style,"AnimationEvent"in window||(delete Na.animationend.animation,delete Na.animationiteration.animation,delete Na.animationstart.animation),"TransitionEvent"in window||delete Na.transitionend.transition);function Xi(t){if(Ml[t])return Ml[t];if(!Na[t])return t;var i=Na[t],s;for(s in i)if(i.hasOwnProperty(s)&&s in Wh)return Ml[t]=i[s];return t}var $h=Xi("animationend"),em=Xi("animationiteration"),tm=Xi("animationstart"),rT=Xi("transitionrun"),sT=Xi("transitionstart"),oT=Xi("transitioncancel"),nm=Xi("transitionend"),im=new Map,am="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll scrollEnd toggle touchMove waiting wheel".split(" ");function sn(t,i){im.set(t,i),Yi(i,[t])}var Qt=[],Ua=0,Pl=0;function mo(){for(var t=Ua,i=Pl=Ua=0;i<t;){var s=Qt[i];Qt[i++]=null;var c=Qt[i];Qt[i++]=null;var f=Qt[i];Qt[i++]=null;var p=Qt[i];if(Qt[i++]=null,c!==null&&f!==null){var v=c.pending;v===null?f.next=f:(f.next=v.next,v.next=f),c.pending=f}p!==0&&rm(s,f,p)}}function po(t,i,s,c){Qt[Ua++]=t,Qt[Ua++]=i,Qt[Ua++]=s,Qt[Ua++]=c,Pl|=c,t.lanes|=c,t=t.alternate,t!==null&&(t.lanes|=c)}function xl(t,i,s,c){return po(t,i,s,c),go(t)}function li(t,i){return po(t,null,null,i),go(t)}function rm(t,i,s){t.lanes|=s;var c=t.alternate;c!==null&&(c.lanes|=s);for(var f=!1,p=t.return;p!==null;)p.childLanes|=s,c=p.alternate,c!==null&&(c.childLanes|=s),p.tag===22&&(t=p.stateNode,t===null||t._visibility&1||(f=!0)),t=p,p=p.return;f&&i!==null&&t.tag===3&&(p=t.stateNode,f=31-Lt(s),p=p.hiddenUpdates,t=p[f],t===null?p[f]=[i]:t.push(i),i.lane=s|536870912)}function go(t){if(50<hs)throw hs=0,Bu=null,Error(r(185));for(var i=t.return;i!==null;)t=i,i=t.return;return t.tag===3?t.stateNode:null}var La={},sm=new WeakMap;function Xt(t,i){if(typeof t=="object"&&t!==null){var s=sm.get(t);return s!==void 0?s:(i={value:t,source:i,stack:he(i)},sm.set(t,i),i)}return{value:t,source:i,stack:he(i)}}var Ia=[],ja=0,vo=null,yo=0,Zt=[],Jt=0,Zi=null,In=1,jn="";function Ji(t,i){Ia[ja++]=yo,Ia[ja++]=vo,vo=t,yo=i}function om(t,i,s){Zt[Jt++]=In,Zt[Jt++]=jn,Zt[Jt++]=Zi,Zi=t;var c=In;t=jn;var f=32-Lt(c)-1;c&=~(1<<f),s+=1;var p=32-Lt(i)+f;if(30<p){var v=f-f%5;p=(c&(1<<v)-1).toString(32),c>>=v,f-=v,In=1<<32-Lt(i)+f|s<<f|c,jn=p+t}else In=1<<p|s<<f|c,jn=t}function Nl(t){t.return!==null&&(Ji(t,1),om(t,1,0))}function Ul(t){for(;t===vo;)vo=Ia[--ja],Ia[ja]=null,yo=Ia[--ja],Ia[ja]=null;for(;t===Zi;)Zi=Zt[--Jt],Zt[Jt]=null,jn=Zt[--Jt],Zt[Jt]=null,In=Zt[--Jt],Zt[Jt]=null}var _t=null,yt=null,we=!1,on=null,Tn=!1,Ll=Error(r(519));function Wi(t){var i=Error(r(418,""));throw Fr(Xt(i,t)),Ll}function cm(t){var i=t.stateNode,s=t.type,c=t.memoizedProps;switch(i[kt]=t,i[Ot]=c,s){case"dialog":Se("cancel",i),Se("close",i);break;case"iframe":case"object":case"embed":Se("load",i);break;case"video":case"audio":for(s=0;s<ps.length;s++)Se(ps[s],i);break;case"source":Se("error",i);break;case"img":case"image":case"link":Se("error",i),Se("load",i);break;case"details":Se("toggle",i);break;case"input":Se("invalid",i),Ch(i,c.value,c.defaultValue,c.checked,c.defaultChecked,c.type,c.name,!0),ao(i);break;case"select":Se("invalid",i);break;case"textarea":Se("invalid",i),Rh(i,c.value,c.defaultValue,c.children),ao(i)}s=c.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||i.textContent===""+s||c.suppressHydrationWarning===!0||vg(i.textContent,s)?(c.popover!=null&&(Se("beforetoggle",i),Se("toggle",i)),c.onScroll!=null&&Se("scroll",i),c.onScrollEnd!=null&&Se("scrollend",i),c.onClick!=null&&(i.onclick=Zo),i=!0):i=!1,i||Wi(t)}function lm(t){for(_t=t.return;_t;)switch(_t.tag){case 3:case 27:Tn=!0;return;case 5:case 13:Tn=!1;return;default:_t=_t.return}}function Hr(t){if(t!==_t)return!1;if(!we)return lm(t),we=!0,!1;var i=!1,s;if((s=t.tag!==3&&t.tag!==27)&&((s=t.tag===5)&&(s=t.type,s=!(s!=="form"&&s!=="button")||nd(t.type,t.memoizedProps)),s=!s),s&&(i=!0),i&&yt&&Wi(t),lm(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(r(317));e:{for(t=t.nextSibling,i=0;t;){if(t.nodeType===8)if(s=t.data,s==="/$"){if(i===0){yt=ln(t.nextSibling);break e}i--}else s!=="$"&&s!=="$!"&&s!=="$?"||i++;t=t.nextSibling}yt=null}}else yt=_t?ln(t.stateNode.nextSibling):null;return!0}function Gr(){yt=_t=null,we=!1}function Fr(t){on===null?on=[t]:on.push(t)}var Yr=Error(r(460)),um=Error(r(474)),Il={then:function(){}};function dm(t){return t=t.status,t==="fulfilled"||t==="rejected"}function bo(){}function fm(t,i,s){switch(s=t[s],s===void 0?t.push(i):s!==i&&(i.then(bo,bo),i=s),i.status){case"fulfilled":return i.value;case"rejected":throw t=i.reason,t===Yr?Error(r(483)):t;default:if(typeof i.status=="string")i.then(bo,bo);else{if(t=Be,t!==null&&100<t.shellSuspendCounter)throw Error(r(482));t=i,t.status="pending",t.then(function(c){if(i.status==="pending"){var f=i;f.status="fulfilled",f.value=c}},function(c){if(i.status==="pending"){var f=i;f.status="rejected",f.reason=c}})}switch(i.status){case"fulfilled":return i.value;case"rejected":throw t=i.reason,t===Yr?Error(r(483)):t}throw Kr=i,Yr}}var Kr=null;function hm(){if(Kr===null)throw Error(r(459));var t=Kr;return Kr=null,t}var Ba=null,Qr=0;function So(t){var i=Qr;return Qr+=1,Ba===null&&(Ba=[]),fm(Ba,t,i)}function Xr(t,i){i=i.props.ref,t.ref=i!==void 0?i:null}function To(t,i){throw i.$$typeof===l?Error(r(525)):(t=Object.prototype.toString.call(i),Error(r(31,t==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":t)))}function mm(t){var i=t._init;return i(t._payload)}function pm(t){function i(x,A){if(t){var N=x.deletions;N===null?(x.deletions=[A],x.flags|=16):N.push(A)}}function s(x,A){if(!t)return null;for(;A!==null;)i(x,A),A=A.sibling;return null}function c(x){for(var A=new Map;x!==null;)x.key!==null?A.set(x.key,x):A.set(x.index,x),x=x.sibling;return A}function f(x,A){return x=Ti(x,A),x.index=0,x.sibling=null,x}function p(x,A,N){return x.index=N,t?(N=x.alternate,N!==null?(N=N.index,N<A?(x.flags|=33554434,A):N):(x.flags|=33554434,A)):(x.flags|=1048576,A)}function v(x){return t&&x.alternate===null&&(x.flags|=33554434),x}function S(x,A,N,G){return A===null||A.tag!==6?(A=Mu(N,x.mode,G),A.return=x,A):(A=f(A,N),A.return=x,A)}function E(x,A,N,G){var re=N.type;return re===h?q(x,A,N.props.children,G,N.key):A!==null&&(A.elementType===re||typeof re=="object"&&re!==null&&re.$$typeof===V&&mm(re)===A.type)?(A=f(A,N.props),Xr(A,N),A.return=x,A):(A=Bo(N.type,N.key,N.props,null,x.mode,G),Xr(A,N),A.return=x,A)}function M(x,A,N,G){return A===null||A.tag!==4||A.stateNode.containerInfo!==N.containerInfo||A.stateNode.implementation!==N.implementation?(A=Pu(N,x.mode,G),A.return=x,A):(A=f(A,N.children||[]),A.return=x,A)}function q(x,A,N,G,re){return A===null||A.tag!==7?(A=ca(N,x.mode,G,re),A.return=x,A):(A=f(A,N),A.return=x,A)}function K(x,A,N){if(typeof A=="string"&&A!==""||typeof A=="number"||typeof A=="bigint")return A=Mu(""+A,x.mode,N),A.return=x,A;if(typeof A=="object"&&A!==null){switch(A.$$typeof){case u:return N=Bo(A.type,A.key,A.props,null,x.mode,N),Xr(N,A),N.return=x,N;case d:return A=Pu(A,x.mode,N),A.return=x,A;case V:var G=A._init;return A=G(A._payload),K(x,A,N)}if(le(A)||H(A))return A=ca(A,x.mode,N,null),A.return=x,A;if(typeof A.then=="function")return K(x,So(A),N);if(A.$$typeof===T)return K(x,Lo(x,A),N);To(x,A)}return null}function L(x,A,N,G){var re=A!==null?A.key:null;if(typeof N=="string"&&N!==""||typeof N=="number"||typeof N=="bigint")return re!==null?null:S(x,A,""+N,G);if(typeof N=="object"&&N!==null){switch(N.$$typeof){case u:return N.key===re?E(x,A,N,G):null;case d:return N.key===re?M(x,A,N,G):null;case V:return re=N._init,N=re(N._payload),L(x,A,N,G)}if(le(N)||H(N))return re!==null?null:q(x,A,N,G,null);if(typeof N.then=="function")return L(x,A,So(N),G);if(N.$$typeof===T)return L(x,A,Lo(x,N),G);To(x,N)}return null}function z(x,A,N,G,re){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return x=x.get(N)||null,S(A,x,""+G,re);if(typeof G=="object"&&G!==null){switch(G.$$typeof){case u:return x=x.get(G.key===null?N:G.key)||null,E(A,x,G,re);case d:return x=x.get(G.key===null?N:G.key)||null,M(A,x,G,re);case V:var ye=G._init;return G=ye(G._payload),z(x,A,N,G,re)}if(le(G)||H(G))return x=x.get(N)||null,q(A,x,G,re,null);if(typeof G.then=="function")return z(x,A,N,So(G),re);if(G.$$typeof===T)return z(x,A,N,Lo(A,G),re);To(A,G)}return null}function se(x,A,N,G){for(var re=null,ye=null,ce=A,de=A=0,pt=null;ce!==null&&de<N.length;de++){ce.index>de?(pt=ce,ce=null):pt=ce.sibling;var Oe=L(x,ce,N[de],G);if(Oe===null){ce===null&&(ce=pt);break}t&&ce&&Oe.alternate===null&&i(x,ce),A=p(Oe,A,de),ye===null?re=Oe:ye.sibling=Oe,ye=Oe,ce=pt}if(de===N.length)return s(x,ce),we&&Ji(x,de),re;if(ce===null){for(;de<N.length;de++)ce=K(x,N[de],G),ce!==null&&(A=p(ce,A,de),ye===null?re=ce:ye.sibling=ce,ye=ce);return we&&Ji(x,de),re}for(ce=c(ce);de<N.length;de++)pt=z(ce,x,de,N[de],G),pt!==null&&(t&&pt.alternate!==null&&ce.delete(pt.key===null?de:pt.key),A=p(pt,A,de),ye===null?re=pt:ye.sibling=pt,ye=pt);return t&&ce.forEach(function(Oi){return i(x,Oi)}),we&&Ji(x,de),re}function me(x,A,N,G){if(N==null)throw Error(r(151));for(var re=null,ye=null,ce=A,de=A=0,pt=null,Oe=N.next();ce!==null&&!Oe.done;de++,Oe=N.next()){ce.index>de?(pt=ce,ce=null):pt=ce.sibling;var Oi=L(x,ce,Oe.value,G);if(Oi===null){ce===null&&(ce=pt);break}t&&ce&&Oi.alternate===null&&i(x,ce),A=p(Oi,A,de),ye===null?re=Oi:ye.sibling=Oi,ye=Oi,ce=pt}if(Oe.done)return s(x,ce),we&&Ji(x,de),re;if(ce===null){for(;!Oe.done;de++,Oe=N.next())Oe=K(x,Oe.value,G),Oe!==null&&(A=p(Oe,A,de),ye===null?re=Oe:ye.sibling=Oe,ye=Oe);return we&&Ji(x,de),re}for(ce=c(ce);!Oe.done;de++,Oe=N.next())Oe=z(ce,x,de,Oe.value,G),Oe!==null&&(t&&Oe.alternate!==null&&ce.delete(Oe.key===null?de:Oe.key),A=p(Oe,A,de),ye===null?re=Oe:ye.sibling=Oe,ye=Oe);return t&&ce.forEach(function(Tk){return i(x,Tk)}),we&&Ji(x,de),re}function Je(x,A,N,G){if(typeof N=="object"&&N!==null&&N.type===h&&N.key===null&&(N=N.props.children),typeof N=="object"&&N!==null){switch(N.$$typeof){case u:e:{for(var re=N.key;A!==null;){if(A.key===re){if(re=N.type,re===h){if(A.tag===7){s(x,A.sibling),G=f(A,N.props.children),G.return=x,x=G;break e}}else if(A.elementType===re||typeof re=="object"&&re!==null&&re.$$typeof===V&&mm(re)===A.type){s(x,A.sibling),G=f(A,N.props),Xr(G,N),G.return=x,x=G;break e}s(x,A);break}else i(x,A);A=A.sibling}N.type===h?(G=ca(N.props.children,x.mode,G,N.key),G.return=x,x=G):(G=Bo(N.type,N.key,N.props,null,x.mode,G),Xr(G,N),G.return=x,x=G)}return v(x);case d:e:{for(re=N.key;A!==null;){if(A.key===re)if(A.tag===4&&A.stateNode.containerInfo===N.containerInfo&&A.stateNode.implementation===N.implementation){s(x,A.sibling),G=f(A,N.children||[]),G.return=x,x=G;break e}else{s(x,A);break}else i(x,A);A=A.sibling}G=Pu(N,x.mode,G),G.return=x,x=G}return v(x);case V:return re=N._init,N=re(N._payload),Je(x,A,N,G)}if(le(N))return se(x,A,N,G);if(H(N)){if(re=H(N),typeof re!="function")throw Error(r(150));return N=re.call(N),me(x,A,N,G)}if(typeof N.then=="function")return Je(x,A,So(N),G);if(N.$$typeof===T)return Je(x,A,Lo(x,N),G);To(x,N)}return typeof N=="string"&&N!==""||typeof N=="number"||typeof N=="bigint"?(N=""+N,A!==null&&A.tag===6?(s(x,A.sibling),G=f(A,N),G.return=x,x=G):(s(x,A),G=Mu(N,x.mode,G),G.return=x,x=G),v(x)):s(x,A)}return function(x,A,N,G){try{Qr=0;var re=Je(x,A,N,G);return Ba=null,re}catch(ce){if(ce===Yr)throw ce;var ye=tn(29,ce,null,x.mode);return ye.lanes=G,ye.return=x,ye}finally{}}}var $i=pm(!0),gm=pm(!1),za=De(null),ko=De(0);function vm(t,i){t=Xn,Ve(ko,t),Ve(za,i),Xn=t|i.baseLanes}function jl(){Ve(ko,Xn),Ve(za,za.current)}function Bl(){Xn=ko.current,it(za),it(ko)}var Wt=De(null),kn=null;function ui(t){var i=t.alternate;Ve(ct,ct.current&1),Ve(Wt,t),kn===null&&(i===null||za.current!==null||i.memoizedState!==null)&&(kn=t)}function ym(t){if(t.tag===22){if(Ve(ct,ct.current),Ve(Wt,t),kn===null){var i=t.alternate;i!==null&&i.memoizedState!==null&&(kn=t)}}else di()}function di(){Ve(ct,ct.current),Ve(Wt,Wt.current)}function Bn(t){it(Wt),kn===t&&(kn=null),it(ct)}var ct=De(0);function Co(t){for(var i=t;i!==null;){if(i.tag===13){var s=i.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||s.data==="$?"||s.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var cT=typeof AbortController<"u"?AbortController:function(){var t=[],i=this.signal={aborted:!1,addEventListener:function(s,c){t.push(c)}};this.abort=function(){i.aborted=!0,t.forEach(function(s){return s()})}},lT=a.unstable_scheduleCallback,uT=a.unstable_NormalPriority,lt={$$typeof:T,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function zl(){return{controller:new cT,data:new Map,refCount:0}}function Zr(t){t.refCount--,t.refCount===0&&lT(uT,function(){t.controller.abort()})}var Jr=null,ql=0,qa=0,Va=null;function dT(t,i){if(Jr===null){var s=Jr=[];ql=0,qa=Ku(),Va={status:"pending",value:void 0,then:function(c){s.push(c)}}}return ql++,i.then(bm,bm),i}function bm(){if(--ql===0&&Jr!==null){Va!==null&&(Va.status="fulfilled");var t=Jr;Jr=null,qa=0,Va=null;for(var i=0;i<t.length;i++)(0,t[i])()}}function fT(t,i){var s=[],c={status:"pending",value:null,reason:null,then:function(f){s.push(f)}};return t.then(function(){c.status="fulfilled",c.value=i;for(var f=0;f<s.length;f++)(0,s[f])(i)},function(f){for(c.status="rejected",c.reason=f,f=0;f<s.length;f++)(0,s[f])(void 0)}),c}var Sm=X.S;X.S=function(t,i){typeof i=="object"&&i!==null&&typeof i.then=="function"&&dT(t,i),Sm!==null&&Sm(t,i)};var ea=De(null);function Vl(){var t=ea.current;return t!==null?t:Be.pooledCache}function Eo(t,i){i===null?Ve(ea,ea.current):Ve(ea,i.pool)}function Tm(){var t=Vl();return t===null?null:{parent:lt._currentValue,pool:t}}var fi=0,ve=null,Pe=null,at=null,Ro=!1,Ha=!1,ta=!1,_o=0,Wr=0,Ga=null,hT=0;function tt(){throw Error(r(321))}function Hl(t,i){if(i===null)return!1;for(var s=0;s<i.length&&s<t.length;s++)if(!It(t[s],i[s]))return!1;return!0}function Gl(t,i,s,c,f,p){return fi=p,ve=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,X.H=t===null||t.memoizedState===null?na:hi,ta=!1,p=s(c,f),ta=!1,Ha&&(p=Cm(i,s,c,f)),km(t),p}function km(t){X.H=Cn;var i=Pe!==null&&Pe.next!==null;if(fi=0,at=Pe=ve=null,Ro=!1,Wr=0,Ga=null,i)throw Error(r(300));t===null||ht||(t=t.dependencies,t!==null&&Uo(t)&&(ht=!0))}function Cm(t,i,s,c){ve=t;var f=0;do{if(Ha&&(Ga=null),Wr=0,Ha=!1,25<=f)throw Error(r(301));if(f+=1,at=Pe=null,t.updateQueue!=null){var p=t.updateQueue;p.lastEffect=null,p.events=null,p.stores=null,p.memoCache!=null&&(p.memoCache.index=0)}X.H=ia,p=i(s,c)}while(Ha);return p}function mT(){var t=X.H,i=t.useState()[0];return i=typeof i.then=="function"?$r(i):i,t=t.useState()[0],(Pe!==null?Pe.memoizedState:null)!==t&&(ve.flags|=1024),i}function Fl(){var t=_o!==0;return _o=0,t}function Yl(t,i,s){i.updateQueue=t.updateQueue,i.flags&=-2053,t.lanes&=~s}function Kl(t){if(Ro){for(t=t.memoizedState;t!==null;){var i=t.queue;i!==null&&(i.pending=null),t=t.next}Ro=!1}fi=0,at=Pe=ve=null,Ha=!1,Wr=_o=0,Ga=null}function At(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return at===null?ve.memoizedState=at=t:at=at.next=t,at}function rt(){if(Pe===null){var t=ve.alternate;t=t!==null?t.memoizedState:null}else t=Pe.next;var i=at===null?ve.memoizedState:at.next;if(i!==null)at=i,Pe=t;else{if(t===null)throw ve.alternate===null?Error(r(467)):Error(r(310));Pe=t,t={memoizedState:Pe.memoizedState,baseState:Pe.baseState,baseQueue:Pe.baseQueue,queue:Pe.queue,next:null},at===null?ve.memoizedState=at=t:at=at.next=t}return at}var wo;wo=function(){return{lastEffect:null,events:null,stores:null,memoCache:null}};function $r(t){var i=Wr;return Wr+=1,Ga===null&&(Ga=[]),t=fm(Ga,t,i),i=ve,(at===null?i.memoizedState:at.next)===null&&(i=i.alternate,X.H=i===null||i.memoizedState===null?na:hi),t}function Oo(t){if(t!==null&&typeof t=="object"){if(typeof t.then=="function")return $r(t);if(t.$$typeof===T)return Ct(t)}throw Error(r(438,String(t)))}function Ql(t){var i=null,s=ve.updateQueue;if(s!==null&&(i=s.memoCache),i==null){var c=ve.alternate;c!==null&&(c=c.updateQueue,c!==null&&(c=c.memoCache,c!=null&&(i={data:c.data.map(function(f){return f.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),s===null&&(s=wo(),ve.updateQueue=s),s.memoCache=i,s=i.data[i.index],s===void 0)for(s=i.data[i.index]=Array(t),c=0;c<t;c++)s[c]=U;return i.index++,s}function zn(t,i){return typeof i=="function"?i(t):i}function Do(t){var i=rt();return Xl(i,Pe,t)}function Xl(t,i,s){var c=t.queue;if(c===null)throw Error(r(311));c.lastRenderedReducer=s;var f=t.baseQueue,p=c.pending;if(p!==null){if(f!==null){var v=f.next;f.next=p.next,p.next=v}i.baseQueue=f=p,c.pending=null}if(p=t.baseState,f===null)t.memoizedState=p;else{i=f.next;var S=v=null,E=null,M=i,q=!1;do{var K=M.lane&-536870913;if(K!==M.lane?(Ee&K)===K:(fi&K)===K){var L=M.revertLane;if(L===0)E!==null&&(E=E.next={lane:0,revertLane:0,action:M.action,hasEagerState:M.hasEagerState,eagerState:M.eagerState,next:null}),K===qa&&(q=!0);else if((fi&L)===L){M=M.next,L===qa&&(q=!0);continue}else K={lane:0,revertLane:M.revertLane,action:M.action,hasEagerState:M.hasEagerState,eagerState:M.eagerState,next:null},E===null?(S=E=K,v=p):E=E.next=K,ve.lanes|=L,ki|=L;K=M.action,ta&&s(p,K),p=M.hasEagerState?M.eagerState:s(p,K)}else L={lane:K,revertLane:M.revertLane,action:M.action,hasEagerState:M.hasEagerState,eagerState:M.eagerState,next:null},E===null?(S=E=L,v=p):E=E.next=L,ve.lanes|=K,ki|=K;M=M.next}while(M!==null&&M!==i);if(E===null?v=p:E.next=S,!It(p,t.memoizedState)&&(ht=!0,q&&(s=Va,s!==null)))throw s;t.memoizedState=p,t.baseState=v,t.baseQueue=E,c.lastRenderedState=p}return f===null&&(c.lanes=0),[t.memoizedState,c.dispatch]}function Zl(t){var i=rt(),s=i.queue;if(s===null)throw Error(r(311));s.lastRenderedReducer=t;var c=s.dispatch,f=s.pending,p=i.memoizedState;if(f!==null){s.pending=null;var v=f=f.next;do p=t(p,v.action),v=v.next;while(v!==f);It(p,i.memoizedState)||(ht=!0),i.memoizedState=p,i.baseQueue===null&&(i.baseState=p),s.lastRenderedState=p}return[p,c]}function Em(t,i,s){var c=ve,f=rt(),p=we;if(p){if(s===void 0)throw Error(r(407));s=s()}else s=i();var v=!It((Pe||f).memoizedState,s);if(v&&(f.memoizedState=s,ht=!0),f=f.queue,$l(wm.bind(null,c,f,t),[t]),f.getSnapshot!==i||v||at!==null&&at.memoizedState.tag&1){if(c.flags|=2048,Fa(9,_m.bind(null,c,f,s,i),{destroy:void 0},null),Be===null)throw Error(r(349));p||(fi&60)!==0||Rm(c,i,s)}return s}function Rm(t,i,s){t.flags|=16384,t={getSnapshot:i,value:s},i=ve.updateQueue,i===null?(i=wo(),ve.updateQueue=i,i.stores=[t]):(s=i.stores,s===null?i.stores=[t]:s.push(t))}function _m(t,i,s,c){i.value=s,i.getSnapshot=c,Om(i)&&Dm(t)}function wm(t,i,s){return s(function(){Om(i)&&Dm(t)})}function Om(t){var i=t.getSnapshot;t=t.value;try{var s=i();return!It(t,s)}catch{return!0}}function Dm(t){var i=li(t,2);i!==null&&wt(i,t,2)}function Jl(t){var i=At();if(typeof t=="function"){var s=t;if(t=s(),ta){si(!0);try{s()}finally{si(!1)}}}return i.memoizedState=i.baseState=t,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:zn,lastRenderedState:t},i}function Am(t,i,s,c){return t.baseState=s,Xl(t,Pe,typeof c=="function"?c:zn)}function pT(t,i,s,c,f){if(Po(t))throw Error(r(485));if(t=i.action,t!==null){var p={payload:f,action:t,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(v){p.listeners.push(v)}};X.T!==null?s(!0):p.isTransition=!1,c(p),s=i.pending,s===null?(p.next=i.pending=p,Mm(i,p)):(p.next=s.next,i.pending=s.next=p)}}function Mm(t,i){var s=i.action,c=i.payload,f=t.state;if(i.isTransition){var p=X.T,v={};X.T=v;try{var S=s(f,c),E=X.S;E!==null&&E(v,S),Pm(t,i,S)}catch(M){Wl(t,i,M)}finally{X.T=p}}else try{p=s(f,c),Pm(t,i,p)}catch(M){Wl(t,i,M)}}function Pm(t,i,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(c){xm(t,i,c)},function(c){return Wl(t,i,c)}):xm(t,i,s)}function xm(t,i,s){i.status="fulfilled",i.value=s,Nm(i),t.state=s,i=t.pending,i!==null&&(s=i.next,s===i?t.pending=null:(s=s.next,i.next=s,Mm(t,s)))}function Wl(t,i,s){var c=t.pending;if(t.pending=null,c!==null){c=c.next;do i.status="rejected",i.reason=s,Nm(i),i=i.next;while(i!==c)}t.action=null}function Nm(t){t=t.listeners;for(var i=0;i<t.length;i++)(0,t[i])()}function Um(t,i){return i}function Lm(t,i){if(we){var s=Be.formState;if(s!==null){e:{var c=ve;if(we){if(yt){t:{for(var f=yt,p=Tn;f.nodeType!==8;){if(!p){f=null;break t}if(f=ln(f.nextSibling),f===null){f=null;break t}}p=f.data,f=p==="F!"||p==="F"?f:null}if(f){yt=ln(f.nextSibling),c=f.data==="F!";break e}}Wi(c)}c=!1}c&&(i=s[0])}}return s=At(),s.memoizedState=s.baseState=i,c={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Um,lastRenderedState:i},s.queue=c,s=ep.bind(null,ve,c),c.dispatch=s,c=Jl(!1),p=au.bind(null,ve,!1,c.queue),c=At(),f={state:i,dispatch:null,action:t,pending:null},c.queue=f,s=pT.bind(null,ve,f,p,s),f.dispatch=s,c.memoizedState=t,[i,s,!1]}function Im(t){var i=rt();return jm(i,Pe,t)}function jm(t,i,s){i=Xl(t,i,Um)[0],t=Do(zn)[0],i=typeof i=="object"&&i!==null&&typeof i.then=="function"?$r(i):i;var c=rt(),f=c.queue,p=f.dispatch;return s!==c.memoizedState&&(ve.flags|=2048,Fa(9,gT.bind(null,f,s),{destroy:void 0},null)),[i,p,t]}function gT(t,i){t.action=i}function Bm(t){var i=rt(),s=Pe;if(s!==null)return jm(i,s,t);rt(),i=i.memoizedState,s=rt();var c=s.queue.dispatch;return s.memoizedState=t,[i,c,!1]}function Fa(t,i,s,c){return t={tag:t,create:i,inst:s,deps:c,next:null},i=ve.updateQueue,i===null&&(i=wo(),ve.updateQueue=i),s=i.lastEffect,s===null?i.lastEffect=t.next=t:(c=s.next,s.next=t,t.next=c,i.lastEffect=t),t}function zm(){return rt().memoizedState}function Ao(t,i,s,c){var f=At();ve.flags|=t,f.memoizedState=Fa(1|i,s,{destroy:void 0},c===void 0?null:c)}function Mo(t,i,s,c){var f=rt();c=c===void 0?null:c;var p=f.memoizedState.inst;Pe!==null&&c!==null&&Hl(c,Pe.memoizedState.deps)?f.memoizedState=Fa(i,s,p,c):(ve.flags|=t,f.memoizedState=Fa(1|i,s,p,c))}function qm(t,i){Ao(8390656,8,t,i)}function $l(t,i){Mo(2048,8,t,i)}function Vm(t,i){return Mo(4,2,t,i)}function Hm(t,i){return Mo(4,4,t,i)}function Gm(t,i){if(typeof i=="function"){t=t();var s=i(t);return function(){typeof s=="function"?s():i(null)}}if(i!=null)return t=t(),i.current=t,function(){i.current=null}}function Fm(t,i,s){s=s!=null?s.concat([t]):null,Mo(4,4,Gm.bind(null,i,t),s)}function eu(){}function Ym(t,i){var s=rt();i=i===void 0?null:i;var c=s.memoizedState;return i!==null&&Hl(i,c[1])?c[0]:(s.memoizedState=[t,i],t)}function Km(t,i){var s=rt();i=i===void 0?null:i;var c=s.memoizedState;if(i!==null&&Hl(i,c[1]))return c[0];if(c=t(),ta){si(!0);try{t()}finally{si(!1)}}return s.memoizedState=[c,i],c}function tu(t,i,s){return s===void 0||(fi&1073741824)!==0?t.memoizedState=i:(t.memoizedState=s,t=Xp(),ve.lanes|=t,ki|=t,s)}function Qm(t,i,s,c){return It(s,i)?s:za.current!==null?(t=tu(t,s,c),It(t,i)||(ht=!0),t):(fi&42)===0?(ht=!0,t.memoizedState=s):(t=Xp(),ve.lanes|=t,ki|=t,i)}function Xm(t,i,s,c,f){var p=ae.p;ae.p=p!==0&&8>p?p:8;var v=X.T,S={};X.T=S,au(t,!1,i,s);try{var E=f(),M=X.S;if(M!==null&&M(S,E),E!==null&&typeof E=="object"&&typeof E.then=="function"){var q=fT(E,c);es(t,i,q,qt(t))}else es(t,i,c,qt(t))}catch(K){es(t,i,{then:function(){},status:"rejected",reason:K},qt())}finally{ae.p=p,X.T=v}}function vT(){}function nu(t,i,s,c){if(t.tag!==5)throw Error(r(476));var f=Zm(t).queue;Xm(t,f,i,Ce,s===null?vT:function(){return Jm(t),s(c)})}function Zm(t){var i=t.memoizedState;if(i!==null)return i;i={memoizedState:Ce,baseState:Ce,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zn,lastRenderedState:Ce},next:null};var s={};return i.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:zn,lastRenderedState:s},next:null},t.memoizedState=i,t=t.alternate,t!==null&&(t.memoizedState=i),i}function Jm(t){var i=Zm(t).next.queue;es(t,i,{},qt())}function iu(){return Ct(Ss)}function Wm(){return rt().memoizedState}function $m(){return rt().memoizedState}function yT(t){for(var i=t.return;i!==null;){switch(i.tag){case 24:case 3:var s=qt();t=gi(s);var c=vi(i,t,s);c!==null&&(wt(c,i,s),is(c,i,s)),i={cache:zl()},t.payload=i;return}i=i.return}}function bT(t,i,s){var c=qt();s={lane:c,revertLane:0,action:s,hasEagerState:!1,eagerState:null,next:null},Po(t)?tp(i,s):(s=xl(t,i,s,c),s!==null&&(wt(s,t,c),np(s,i,c)))}function ep(t,i,s){var c=qt();es(t,i,s,c)}function es(t,i,s,c){var f={lane:c,revertLane:0,action:s,hasEagerState:!1,eagerState:null,next:null};if(Po(t))tp(i,f);else{var p=t.alternate;if(t.lanes===0&&(p===null||p.lanes===0)&&(p=i.lastRenderedReducer,p!==null))try{var v=i.lastRenderedState,S=p(v,s);if(f.hasEagerState=!0,f.eagerState=S,It(S,v))return po(t,i,f,0),Be===null&&mo(),!1}catch{}finally{}if(s=xl(t,i,f,c),s!==null)return wt(s,t,c),np(s,i,c),!0}return!1}function au(t,i,s,c){if(c={lane:2,revertLane:Ku(),action:c,hasEagerState:!1,eagerState:null,next:null},Po(t)){if(i)throw Error(r(479))}else i=xl(t,s,c,2),i!==null&&wt(i,t,2)}function Po(t){var i=t.alternate;return t===ve||i!==null&&i===ve}function tp(t,i){Ha=Ro=!0;var s=t.pending;s===null?i.next=i:(i.next=s.next,s.next=i),t.pending=i}function np(t,i,s){if((s&4194176)!==0){var c=i.lanes;c&=t.pendingLanes,s|=c,i.lanes=s,hh(t,s)}}var Cn={readContext:Ct,use:Oo,useCallback:tt,useContext:tt,useEffect:tt,useImperativeHandle:tt,useLayoutEffect:tt,useInsertionEffect:tt,useMemo:tt,useReducer:tt,useRef:tt,useState:tt,useDebugValue:tt,useDeferredValue:tt,useTransition:tt,useSyncExternalStore:tt,useId:tt};Cn.useCacheRefresh=tt,Cn.useMemoCache=tt,Cn.useHostTransitionStatus=tt,Cn.useFormState=tt,Cn.useActionState=tt,Cn.useOptimistic=tt;var na={readContext:Ct,use:Oo,useCallback:function(t,i){return At().memoizedState=[t,i===void 0?null:i],t},useContext:Ct,useEffect:qm,useImperativeHandle:function(t,i,s){s=s!=null?s.concat([t]):null,Ao(4194308,4,Gm.bind(null,i,t),s)},useLayoutEffect:function(t,i){return Ao(4194308,4,t,i)},useInsertionEffect:function(t,i){Ao(4,2,t,i)},useMemo:function(t,i){var s=At();i=i===void 0?null:i;var c=t();if(ta){si(!0);try{t()}finally{si(!1)}}return s.memoizedState=[c,i],c},useReducer:function(t,i,s){var c=At();if(s!==void 0){var f=s(i);if(ta){si(!0);try{s(i)}finally{si(!1)}}}else f=i;return c.memoizedState=c.baseState=f,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:f},c.queue=t,t=t.dispatch=bT.bind(null,ve,t),[c.memoizedState,t]},useRef:function(t){var i=At();return t={current:t},i.memoizedState=t},useState:function(t){t=Jl(t);var i=t.queue,s=ep.bind(null,ve,i);return i.dispatch=s,[t.memoizedState,s]},useDebugValue:eu,useDeferredValue:function(t,i){var s=At();return tu(s,t,i)},useTransition:function(){var t=Jl(!1);return t=Xm.bind(null,ve,t.queue,!0,!1),At().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,i,s){var c=ve,f=At();if(we){if(s===void 0)throw Error(r(407));s=s()}else{if(s=i(),Be===null)throw Error(r(349));(Ee&60)!==0||Rm(c,i,s)}f.memoizedState=s;var p={value:s,getSnapshot:i};return f.queue=p,qm(wm.bind(null,c,p,t),[t]),c.flags|=2048,Fa(9,_m.bind(null,c,p,s,i),{destroy:void 0},null),s},useId:function(){var t=At(),i=Be.identifierPrefix;if(we){var s=jn,c=In;s=(c&~(1<<32-Lt(c)-1)).toString(32)+s,i=":"+i+"R"+s,s=_o++,0<s&&(i+="H"+s.toString(32)),i+=":"}else s=hT++,i=":"+i+"r"+s.toString(32)+":";return t.memoizedState=i},useCacheRefresh:function(){return At().memoizedState=yT.bind(null,ve)}};na.useMemoCache=Ql,na.useHostTransitionStatus=iu,na.useFormState=Lm,na.useActionState=Lm,na.useOptimistic=function(t){var i=At();i.memoizedState=i.baseState=t;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=s,i=au.bind(null,ve,!0,s),s.dispatch=i,[t,i]};var hi={readContext:Ct,use:Oo,useCallback:Ym,useContext:Ct,useEffect:$l,useImperativeHandle:Fm,useInsertionEffect:Vm,useLayoutEffect:Hm,useMemo:Km,useReducer:Do,useRef:zm,useState:function(){return Do(zn)},useDebugValue:eu,useDeferredValue:function(t,i){var s=rt();return Qm(s,Pe.memoizedState,t,i)},useTransition:function(){var t=Do(zn)[0],i=rt().memoizedState;return[typeof t=="boolean"?t:$r(t),i]},useSyncExternalStore:Em,useId:Wm};hi.useCacheRefresh=$m,hi.useMemoCache=Ql,hi.useHostTransitionStatus=iu,hi.useFormState=Im,hi.useActionState=Im,hi.useOptimistic=function(t,i){var s=rt();return Am(s,Pe,t,i)};var ia={readContext:Ct,use:Oo,useCallback:Ym,useContext:Ct,useEffect:$l,useImperativeHandle:Fm,useInsertionEffect:Vm,useLayoutEffect:Hm,useMemo:Km,useReducer:Zl,useRef:zm,useState:function(){return Zl(zn)},useDebugValue:eu,useDeferredValue:function(t,i){var s=rt();return Pe===null?tu(s,t,i):Qm(s,Pe.memoizedState,t,i)},useTransition:function(){var t=Zl(zn)[0],i=rt().memoizedState;return[typeof t=="boolean"?t:$r(t),i]},useSyncExternalStore:Em,useId:Wm};ia.useCacheRefresh=$m,ia.useMemoCache=Ql,ia.useHostTransitionStatus=iu,ia.useFormState=Bm,ia.useActionState=Bm,ia.useOptimistic=function(t,i){var s=rt();return Pe!==null?Am(s,Pe,t,i):(s.baseState=t,[t,s.queue.dispatch])};function ru(t,i,s,c){i=t.memoizedState,s=s(c,i),s=s==null?i:J({},i,s),t.memoizedState=s,t.lanes===0&&(t.updateQueue.baseState=s)}var su={isMounted:function(t){return(t=t._reactInternals)?ue(t)===t:!1},enqueueSetState:function(t,i,s){t=t._reactInternals;var c=qt(),f=gi(c);f.payload=i,s!=null&&(f.callback=s),i=vi(t,f,c),i!==null&&(wt(i,t,c),is(i,t,c))},enqueueReplaceState:function(t,i,s){t=t._reactInternals;var c=qt(),f=gi(c);f.tag=1,f.payload=i,s!=null&&(f.callback=s),i=vi(t,f,c),i!==null&&(wt(i,t,c),is(i,t,c))},enqueueForceUpdate:function(t,i){t=t._reactInternals;var s=qt(),c=gi(s);c.tag=2,i!=null&&(c.callback=i),i=vi(t,c,s),i!==null&&(wt(i,t,s),is(i,t,s))}};function ip(t,i,s,c,f,p,v){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(c,p,v):i.prototype&&i.prototype.isPureReactComponent?!qr(s,c)||!qr(f,p):!0}function ap(t,i,s,c){t=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(s,c),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(s,c),i.state!==t&&su.enqueueReplaceState(i,i.state,null)}function aa(t,i){var s=i;if("ref"in i){s={};for(var c in i)c!=="ref"&&(s[c]=i[c])}if(t=t.defaultProps){s===i&&(s=J({},s));for(var f in t)s[f]===void 0&&(s[f]=t[f])}return s}var xo=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var i=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(i))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)};function rp(t){xo(t)}function sp(t){console.error(t)}function op(t){xo(t)}function No(t,i){try{var s=t.onUncaughtError;s(i.value,{componentStack:i.stack})}catch(c){setTimeout(function(){throw c})}}function cp(t,i,s){try{var c=t.onCaughtError;c(s.value,{componentStack:s.stack,errorBoundary:i.tag===1?i.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function ou(t,i,s){return s=gi(s),s.tag=3,s.payload={element:null},s.callback=function(){No(t,i)},s}function lp(t){return t=gi(t),t.tag=3,t}function up(t,i,s,c){var f=s.type.getDerivedStateFromError;if(typeof f=="function"){var p=c.value;t.payload=function(){return f(p)},t.callback=function(){cp(i,s,c)}}var v=s.stateNode;v!==null&&typeof v.componentDidCatch=="function"&&(t.callback=function(){cp(i,s,c),typeof f!="function"&&(Ci===null?Ci=new Set([this]):Ci.add(this));var S=c.stack;this.componentDidCatch(c.value,{componentStack:S!==null?S:""})})}function ST(t,i,s,c,f){if(s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){if(i=s.alternate,i!==null&&ns(i,s,f,!0),s=Wt.current,s!==null){switch(s.tag){case 13:return kn===null?Vu():s.alternate===null&&Ze===0&&(Ze=3),s.flags&=-257,s.flags|=65536,s.lanes=f,c===Il?s.flags|=16384:(i=s.updateQueue,i===null?s.updateQueue=new Set([c]):i.add(c),Gu(t,c,f)),!1;case 22:return s.flags|=65536,c===Il?s.flags|=16384:(i=s.updateQueue,i===null?(i={transitions:null,markerInstances:null,retryQueue:new Set([c])},s.updateQueue=i):(s=i.retryQueue,s===null?i.retryQueue=new Set([c]):s.add(c)),Gu(t,c,f)),!1}throw Error(r(435,s.tag))}return Gu(t,c,f),Vu(),!1}if(we)return i=Wt.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=f,c!==Ll&&(t=Error(r(422),{cause:c}),Fr(Xt(t,s)))):(c!==Ll&&(i=Error(r(423),{cause:c}),Fr(Xt(i,s))),t=t.current.alternate,t.flags|=65536,f&=-f,t.lanes|=f,c=Xt(c,s),f=ou(t.stateNode,c,f),ku(t,f),Ze!==4&&(Ze=2)),!1;var p=Error(r(520),{cause:c});if(p=Xt(p,s),ds===null?ds=[p]:ds.push(p),Ze!==4&&(Ze=2),i===null)return!0;c=Xt(c,s),s=i;do{switch(s.tag){case 3:return s.flags|=65536,t=f&-f,s.lanes|=t,t=ou(s.stateNode,c,t),ku(s,t),!1;case 1:if(i=s.type,p=s.stateNode,(s.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||p!==null&&typeof p.componentDidCatch=="function"&&(Ci===null||!Ci.has(p))))return s.flags|=65536,f&=-f,s.lanes|=f,f=lp(f),up(f,t,s,c),ku(s,f),!1}s=s.return}while(s!==null);return!1}var dp=Error(r(461)),ht=!1;function bt(t,i,s,c){i.child=t===null?gm(i,null,s,c):$i(i,t.child,s,c)}function fp(t,i,s,c,f){s=s.render;var p=i.ref;if("ref"in c){var v={};for(var S in c)S!=="ref"&&(v[S]=c[S])}else v=c;return sa(i),c=Gl(t,i,s,v,p,f),S=Fl(),t!==null&&!ht?(Yl(t,i,f),qn(t,i,f)):(we&&S&&Nl(i),i.flags|=1,bt(t,i,c,f),i.child)}function hp(t,i,s,c,f){if(t===null){var p=s.type;return typeof p=="function"&&!Au(p)&&p.defaultProps===void 0&&s.compare===null?(i.tag=15,i.type=p,mp(t,i,p,c,f)):(t=Bo(s.type,null,c,i,i.mode,f),t.ref=i.ref,t.return=i,i.child=t)}if(p=t.child,!gu(t,f)){var v=p.memoizedProps;if(s=s.compare,s=s!==null?s:qr,s(v,c)&&t.ref===i.ref)return qn(t,i,f)}return i.flags|=1,t=Ti(p,c),t.ref=i.ref,t.return=i,i.child=t}function mp(t,i,s,c,f){if(t!==null){var p=t.memoizedProps;if(qr(p,c)&&t.ref===i.ref)if(ht=!1,i.pendingProps=c=p,gu(t,f))(t.flags&131072)!==0&&(ht=!0);else return i.lanes=t.lanes,qn(t,i,f)}return cu(t,i,s,c,f)}function pp(t,i,s){var c=i.pendingProps,f=c.children,p=(i.stateNode._pendingVisibility&2)!==0,v=t!==null?t.memoizedState:null;if(ts(t,i),c.mode==="hidden"||p){if((i.flags&128)!==0){if(c=v!==null?v.baseLanes|s:s,t!==null){for(f=i.child=t.child,p=0;f!==null;)p=p|f.lanes|f.childLanes,f=f.sibling;i.childLanes=p&~c}else i.childLanes=0,i.child=null;return gp(t,i,c,s)}if((s&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},t!==null&&Eo(i,v!==null?v.cachePool:null),v!==null?vm(i,v):jl(),ym(i);else return i.lanes=i.childLanes=536870912,gp(t,i,v!==null?v.baseLanes|s:s,s)}else v!==null?(Eo(i,v.cachePool),vm(i,v),di(),i.memoizedState=null):(t!==null&&Eo(i,null),jl(),di());return bt(t,i,f,s),i.child}function gp(t,i,s,c){var f=Vl();return f=f===null?null:{parent:lt._currentValue,pool:f},i.memoizedState={baseLanes:s,cachePool:f},t!==null&&Eo(i,null),jl(),ym(i),t!==null&&ns(t,i,c,!0),null}function ts(t,i){var s=i.ref;if(s===null)t!==null&&t.ref!==null&&(i.flags|=2097664);else{if(typeof s!="function"&&typeof s!="object")throw Error(r(284));(t===null||t.ref!==s)&&(i.flags|=2097664)}}function cu(t,i,s,c,f){return sa(i),s=Gl(t,i,s,c,void 0,f),c=Fl(),t!==null&&!ht?(Yl(t,i,f),qn(t,i,f)):(we&&c&&Nl(i),i.flags|=1,bt(t,i,s,f),i.child)}function vp(t,i,s,c,f,p){return sa(i),i.updateQueue=null,s=Cm(i,c,s,f),km(t),c=Fl(),t!==null&&!ht?(Yl(t,i,p),qn(t,i,p)):(we&&c&&Nl(i),i.flags|=1,bt(t,i,s,p),i.child)}function yp(t,i,s,c,f){if(sa(i),i.stateNode===null){var p=La,v=s.contextType;typeof v=="object"&&v!==null&&(p=Ct(v)),p=new s(c,p),i.memoizedState=p.state!==null&&p.state!==void 0?p.state:null,p.updater=su,i.stateNode=p,p._reactInternals=i,p=i.stateNode,p.props=c,p.state=i.memoizedState,p.refs={},Su(i),v=s.contextType,p.context=typeof v=="object"&&v!==null?Ct(v):La,p.state=i.memoizedState,v=s.getDerivedStateFromProps,typeof v=="function"&&(ru(i,s,v,c),p.state=i.memoizedState),typeof s.getDerivedStateFromProps=="function"||typeof p.getSnapshotBeforeUpdate=="function"||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(v=p.state,typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount(),v!==p.state&&su.enqueueReplaceState(p,p.state,null),rs(i,c,p,f),as(),p.state=i.memoizedState),typeof p.componentDidMount=="function"&&(i.flags|=4194308),c=!0}else if(t===null){p=i.stateNode;var S=i.memoizedProps,E=aa(s,S);p.props=E;var M=p.context,q=s.contextType;v=La,typeof q=="object"&&q!==null&&(v=Ct(q));var K=s.getDerivedStateFromProps;q=typeof K=="function"||typeof p.getSnapshotBeforeUpdate=="function",S=i.pendingProps!==S,q||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(S||M!==v)&&ap(i,p,c,v),pi=!1;var L=i.memoizedState;p.state=L,rs(i,c,p,f),as(),M=i.memoizedState,S||L!==M||pi?(typeof K=="function"&&(ru(i,s,K,c),M=i.memoizedState),(E=pi||ip(i,s,E,c,L,M,v))?(q||typeof p.UNSAFE_componentWillMount!="function"&&typeof p.componentWillMount!="function"||(typeof p.componentWillMount=="function"&&p.componentWillMount(),typeof p.UNSAFE_componentWillMount=="function"&&p.UNSAFE_componentWillMount()),typeof p.componentDidMount=="function"&&(i.flags|=4194308)):(typeof p.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=c,i.memoizedState=M),p.props=c,p.state=M,p.context=v,c=E):(typeof p.componentDidMount=="function"&&(i.flags|=4194308),c=!1)}else{p=i.stateNode,Tu(t,i),v=i.memoizedProps,q=aa(s,v),p.props=q,K=i.pendingProps,L=p.context,M=s.contextType,E=La,typeof M=="object"&&M!==null&&(E=Ct(M)),S=s.getDerivedStateFromProps,(M=typeof S=="function"||typeof p.getSnapshotBeforeUpdate=="function")||typeof p.UNSAFE_componentWillReceiveProps!="function"&&typeof p.componentWillReceiveProps!="function"||(v!==K||L!==E)&&ap(i,p,c,E),pi=!1,L=i.memoizedState,p.state=L,rs(i,c,p,f),as();var z=i.memoizedState;v!==K||L!==z||pi||t!==null&&t.dependencies!==null&&Uo(t.dependencies)?(typeof S=="function"&&(ru(i,s,S,c),z=i.memoizedState),(q=pi||ip(i,s,q,c,L,z,E)||t!==null&&t.dependencies!==null&&Uo(t.dependencies))?(M||typeof p.UNSAFE_componentWillUpdate!="function"&&typeof p.componentWillUpdate!="function"||(typeof p.componentWillUpdate=="function"&&p.componentWillUpdate(c,z,E),typeof p.UNSAFE_componentWillUpdate=="function"&&p.UNSAFE_componentWillUpdate(c,z,E)),typeof p.componentDidUpdate=="function"&&(i.flags|=4),typeof p.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof p.componentDidUpdate!="function"||v===t.memoizedProps&&L===t.memoizedState||(i.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||v===t.memoizedProps&&L===t.memoizedState||(i.flags|=1024),i.memoizedProps=c,i.memoizedState=z),p.props=c,p.state=z,p.context=E,c=q):(typeof p.componentDidUpdate!="function"||v===t.memoizedProps&&L===t.memoizedState||(i.flags|=4),typeof p.getSnapshotBeforeUpdate!="function"||v===t.memoizedProps&&L===t.memoizedState||(i.flags|=1024),c=!1)}return p=c,ts(t,i),c=(i.flags&128)!==0,p||c?(p=i.stateNode,s=c&&typeof s.getDerivedStateFromError!="function"?null:p.render(),i.flags|=1,t!==null&&c?(i.child=$i(i,t.child,null,f),i.child=$i(i,null,s,f)):bt(t,i,s,f),i.memoizedState=p.state,t=i.child):t=qn(t,i,f),t}function bp(t,i,s,c){return Gr(),i.flags|=256,bt(t,i,s,c),i.child}var lu={dehydrated:null,treeContext:null,retryLane:0};function uu(t){return{baseLanes:t,cachePool:Tm()}}function du(t,i,s){return t=t!==null?t.childLanes&~s:0,i&&(t|=nn),t}function Sp(t,i,s){var c=i.pendingProps,f=!1,p=(i.flags&128)!==0,v;if((v=p)||(v=t!==null&&t.memoizedState===null?!1:(ct.current&2)!==0),v&&(f=!0,i.flags&=-129),v=(i.flags&32)!==0,i.flags&=-33,t===null){if(we){if(f?ui(i):di(),we){var S=yt,E;if(E=S){e:{for(E=S,S=Tn;E.nodeType!==8;){if(!S){S=null;break e}if(E=ln(E.nextSibling),E===null){S=null;break e}}S=E}S!==null?(i.memoizedState={dehydrated:S,treeContext:Zi!==null?{id:In,overflow:jn}:null,retryLane:536870912},E=tn(18,null,null,0),E.stateNode=S,E.return=i,i.child=E,_t=i,yt=null,E=!0):E=!1}E||Wi(i)}if(S=i.memoizedState,S!==null&&(S=S.dehydrated,S!==null))return S.data==="$!"?i.lanes=16:i.lanes=536870912,null;Bn(i)}return S=c.children,c=c.fallback,f?(di(),f=i.mode,S=hu({mode:"hidden",children:S},f),c=ca(c,f,s,null),S.return=i,c.return=i,S.sibling=c,i.child=S,f=i.child,f.memoizedState=uu(s),f.childLanes=du(t,v,s),i.memoizedState=lu,c):(ui(i),fu(i,S))}if(E=t.memoizedState,E!==null&&(S=E.dehydrated,S!==null)){if(p)i.flags&256?(ui(i),i.flags&=-257,i=mu(t,i,s)):i.memoizedState!==null?(di(),i.child=t.child,i.flags|=128,i=null):(di(),f=c.fallback,S=i.mode,c=hu({mode:"visible",children:c.children},S),f=ca(f,S,s,null),f.flags|=2,c.return=i,f.return=i,c.sibling=f,i.child=c,$i(i,t.child,null,s),c=i.child,c.memoizedState=uu(s),c.childLanes=du(t,v,s),i.memoizedState=lu,i=f);else if(ui(i),S.data==="$!"){if(v=S.nextSibling&&S.nextSibling.dataset,v)var M=v.dgst;v=M,c=Error(r(419)),c.stack="",c.digest=v,Fr({value:c,source:null,stack:null}),i=mu(t,i,s)}else if(ht||ns(t,i,s,!1),v=(s&t.childLanes)!==0,ht||v){if(v=Be,v!==null){if(c=s&-s,(c&42)!==0)c=1;else switch(c){case 2:c=1;break;case 8:c=4;break;case 32:c=16;break;case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:c=64;break;case 268435456:c=134217728;break;default:c=0}if(c=(c&(v.suspendedLanes|s))!==0?0:c,c!==0&&c!==E.retryLane)throw E.retryLane=c,li(t,c),wt(v,t,c),dp}S.data==="$?"||Vu(),i=mu(t,i,s)}else S.data==="$?"?(i.flags|=128,i.child=t.child,i=UT.bind(null,t),S._reactRetry=i,i=null):(t=E.treeContext,yt=ln(S.nextSibling),_t=i,we=!0,on=null,Tn=!1,t!==null&&(Zt[Jt++]=In,Zt[Jt++]=jn,Zt[Jt++]=Zi,In=t.id,jn=t.overflow,Zi=i),i=fu(i,c.children),i.flags|=4096);return i}return f?(di(),f=c.fallback,S=i.mode,E=t.child,M=E.sibling,c=Ti(E,{mode:"hidden",children:c.children}),c.subtreeFlags=E.subtreeFlags&31457280,M!==null?f=Ti(M,f):(f=ca(f,S,s,null),f.flags|=2),f.return=i,c.return=i,c.sibling=f,i.child=c,c=f,f=i.child,S=t.child.memoizedState,S===null?S=uu(s):(E=S.cachePool,E!==null?(M=lt._currentValue,E=E.parent!==M?{parent:M,pool:M}:E):E=Tm(),S={baseLanes:S.baseLanes|s,cachePool:E}),f.memoizedState=S,f.childLanes=du(t,v,s),i.memoizedState=lu,c):(ui(i),s=t.child,t=s.sibling,s=Ti(s,{mode:"visible",children:c.children}),s.return=i,s.sibling=null,t!==null&&(v=i.deletions,v===null?(i.deletions=[t],i.flags|=16):v.push(t)),i.child=s,i.memoizedState=null,s)}function fu(t,i){return i=hu({mode:"visible",children:i},t.mode),i.return=t,t.child=i}function hu(t,i){return Yp(t,i,0,null)}function mu(t,i,s){return $i(i,t.child,null,s),t=fu(i,i.pendingProps.children),t.flags|=2,i.memoizedState=null,t}function Tp(t,i,s){t.lanes|=i;var c=t.alternate;c!==null&&(c.lanes|=i),yu(t.return,i,s)}function pu(t,i,s,c,f){var p=t.memoizedState;p===null?t.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:c,tail:s,tailMode:f}:(p.isBackwards=i,p.rendering=null,p.renderingStartTime=0,p.last=c,p.tail=s,p.tailMode=f)}function kp(t,i,s){var c=i.pendingProps,f=c.revealOrder,p=c.tail;if(bt(t,i,c.children,s),c=ct.current,(c&2)!==0)c=c&1|2,i.flags|=128;else{if(t!==null&&(t.flags&128)!==0)e:for(t=i.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Tp(t,s,i);else if(t.tag===19)Tp(t,s,i);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===i)break e;for(;t.sibling===null;){if(t.return===null||t.return===i)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}c&=1}switch(Ve(ct,c),f){case"forwards":for(s=i.child,f=null;s!==null;)t=s.alternate,t!==null&&Co(t)===null&&(f=s),s=s.sibling;s=f,s===null?(f=i.child,i.child=null):(f=s.sibling,s.sibling=null),pu(i,!1,f,s,p);break;case"backwards":for(s=null,f=i.child,i.child=null;f!==null;){if(t=f.alternate,t!==null&&Co(t)===null){i.child=f;break}t=f.sibling,f.sibling=s,s=f,f=t}pu(i,!0,s,null,p);break;case"together":pu(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function qn(t,i,s){if(t!==null&&(i.dependencies=t.dependencies),ki|=i.lanes,(s&i.childLanes)===0)if(t!==null){if(ns(t,i,s,!1),(s&i.childLanes)===0)return null}else return null;if(t!==null&&i.child!==t.child)throw Error(r(153));if(i.child!==null){for(t=i.child,s=Ti(t,t.pendingProps),i.child=s,s.return=i;t.sibling!==null;)t=t.sibling,s=s.sibling=Ti(t,t.pendingProps),s.return=i;s.sibling=null}return i.child}function gu(t,i){return(t.lanes&i)!==0?!0:(t=t.dependencies,!!(t!==null&&Uo(t)))}function TT(t,i,s){switch(i.tag){case 3:Zs(i,i.stateNode.containerInfo),mi(i,lt,t.memoizedState.cache),Gr();break;case 27:case 5:sl(i);break;case 4:Zs(i,i.stateNode.containerInfo);break;case 10:mi(i,i.type,i.memoizedProps.value);break;case 13:var c=i.memoizedState;if(c!==null)return c.dehydrated!==null?(ui(i),i.flags|=128,null):(s&i.child.childLanes)!==0?Sp(t,i,s):(ui(i),t=qn(t,i,s),t!==null?t.sibling:null);ui(i);break;case 19:var f=(t.flags&128)!==0;if(c=(s&i.childLanes)!==0,c||(ns(t,i,s,!1),c=(s&i.childLanes)!==0),f){if(c)return kp(t,i,s);i.flags|=128}if(f=i.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),Ve(ct,ct.current),c)break;return null;case 22:case 23:return i.lanes=0,pp(t,i,s);case 24:mi(i,lt,t.memoizedState.cache)}return qn(t,i,s)}function Cp(t,i,s){if(t!==null)if(t.memoizedProps!==i.pendingProps)ht=!0;else{if(!gu(t,s)&&(i.flags&128)===0)return ht=!1,TT(t,i,s);ht=(t.flags&131072)!==0}else ht=!1,we&&(i.flags&1048576)!==0&&om(i,yo,i.index);switch(i.lanes=0,i.tag){case 16:e:{t=i.pendingProps;var c=i.elementType,f=c._init;if(c=f(c._payload),i.type=c,typeof c=="function")Au(c)?(t=aa(c,t),i.tag=1,i=yp(null,i,c,t,s)):(i.tag=0,i=cu(null,i,c,t,s));else{if(c!=null){if(f=c.$$typeof,f===C){i.tag=11,i=fp(null,i,c,t,s);break e}else if(f===O){i.tag=14,i=hp(null,i,c,t,s);break e}}throw i=ie(c)||c,Error(r(306,i,""))}}return i;case 0:return cu(t,i,i.type,i.pendingProps,s);case 1:return c=i.type,f=aa(c,i.pendingProps),yp(t,i,c,f,s);case 3:e:{if(Zs(i,i.stateNode.containerInfo),t===null)throw Error(r(387));var p=i.pendingProps;f=i.memoizedState,c=f.element,Tu(t,i),rs(i,p,null,s);var v=i.memoizedState;if(p=v.cache,mi(i,lt,p),p!==f.cache&&bu(i,[lt],s,!0),as(),p=v.element,f.isDehydrated)if(f={element:p,isDehydrated:!1,cache:v.cache},i.updateQueue.baseState=f,i.memoizedState=f,i.flags&256){i=bp(t,i,p,s);break e}else if(p!==c){c=Xt(Error(r(424)),i),Fr(c),i=bp(t,i,p,s);break e}else for(yt=ln(i.stateNode.containerInfo.firstChild),_t=i,we=!0,on=null,Tn=!0,s=gm(i,null,p,s),i.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(Gr(),p===c){i=qn(t,i,s);break e}bt(t,i,p,s)}i=i.child}return i;case 26:return ts(t,i),t===null?(s=_g(i.type,null,i.pendingProps,null))?i.memoizedState=s:we||(s=i.type,t=i.pendingProps,c=Jo(ri.current).createElement(s),c[kt]=i,c[Ot]=t,St(c,s,t),ft(c),i.stateNode=c):i.memoizedState=_g(i.type,t.memoizedProps,i.pendingProps,t.memoizedState),null;case 27:return sl(i),t===null&&we&&(c=i.stateNode=Cg(i.type,i.pendingProps,ri.current),_t=i,Tn=!0,yt=ln(c.firstChild)),c=i.pendingProps.children,t!==null||we?bt(t,i,c,s):i.child=$i(i,null,c,s),ts(t,i),i.child;case 5:return t===null&&we&&((f=c=yt)&&(c=JT(c,i.type,i.pendingProps,Tn),c!==null?(i.stateNode=c,_t=i,yt=ln(c.firstChild),Tn=!1,f=!0):f=!1),f||Wi(i)),sl(i),f=i.type,p=i.pendingProps,v=t!==null?t.memoizedProps:null,c=p.children,nd(f,p)?c=null:v!==null&&nd(f,v)&&(i.flags|=32),i.memoizedState!==null&&(f=Gl(t,i,mT,null,null,s),Ss._currentValue=f),ts(t,i),bt(t,i,c,s),i.child;case 6:return t===null&&we&&((t=s=yt)&&(s=WT(s,i.pendingProps,Tn),s!==null?(i.stateNode=s,_t=i,yt=null,t=!0):t=!1),t||Wi(i)),null;case 13:return Sp(t,i,s);case 4:return Zs(i,i.stateNode.containerInfo),c=i.pendingProps,t===null?i.child=$i(i,null,c,s):bt(t,i,c,s),i.child;case 11:return fp(t,i,i.type,i.pendingProps,s);case 7:return bt(t,i,i.pendingProps,s),i.child;case 8:return bt(t,i,i.pendingProps.children,s),i.child;case 12:return bt(t,i,i.pendingProps.children,s),i.child;case 10:return c=i.pendingProps,mi(i,i.type,c.value),bt(t,i,c.children,s),i.child;case 9:return f=i.type._context,c=i.pendingProps.children,sa(i),f=Ct(f),c=c(f),i.flags|=1,bt(t,i,c,s),i.child;case 14:return hp(t,i,i.type,i.pendingProps,s);case 15:return mp(t,i,i.type,i.pendingProps,s);case 19:return kp(t,i,s);case 22:return pp(t,i,s);case 24:return sa(i),c=Ct(lt),t===null?(f=Vl(),f===null&&(f=Be,p=zl(),f.pooledCache=p,p.refCount++,p!==null&&(f.pooledCacheLanes|=s),f=p),i.memoizedState={parent:c,cache:f},Su(i),mi(i,lt,f)):((t.lanes&s)!==0&&(Tu(t,i),rs(i,null,null,s),as()),f=t.memoizedState,p=i.memoizedState,f.parent!==c?(f={parent:c,cache:c},i.memoizedState=f,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=f),mi(i,lt,c)):(c=p.cache,mi(i,lt,c),c!==f.cache&&bu(i,[lt],s,!0))),bt(t,i,i.pendingProps.children,s),i.child;case 29:throw i.pendingProps}throw Error(r(156,i.tag))}var vu=De(null),ra=null,Vn=null;function mi(t,i,s){Ve(vu,i._currentValue),i._currentValue=s}function Hn(t){t._currentValue=vu.current,it(vu)}function yu(t,i,s){for(;t!==null;){var c=t.alternate;if((t.childLanes&i)!==i?(t.childLanes|=i,c!==null&&(c.childLanes|=i)):c!==null&&(c.childLanes&i)!==i&&(c.childLanes|=i),t===s)break;t=t.return}}function bu(t,i,s,c){var f=t.child;for(f!==null&&(f.return=t);f!==null;){var p=f.dependencies;if(p!==null){var v=f.child;p=p.firstContext;e:for(;p!==null;){var S=p;p=f;for(var E=0;E<i.length;E++)if(S.context===i[E]){p.lanes|=s,S=p.alternate,S!==null&&(S.lanes|=s),yu(p.return,s,t),c||(v=null);break e}p=S.next}}else if(f.tag===18){if(v=f.return,v===null)throw Error(r(341));v.lanes|=s,p=v.alternate,p!==null&&(p.lanes|=s),yu(v,s,t),v=null}else v=f.child;if(v!==null)v.return=f;else for(v=f;v!==null;){if(v===t){v=null;break}if(f=v.sibling,f!==null){f.return=v.return,v=f;break}v=v.return}f=v}}function ns(t,i,s,c){t=null;for(var f=i,p=!1;f!==null;){if(!p){if((f.flags&524288)!==0)p=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var v=f.alternate;if(v===null)throw Error(r(387));if(v=v.memoizedProps,v!==null){var S=f.type;It(f.pendingProps.value,v.value)||(t!==null?t.push(S):t=[S])}}else if(f===Xs.current){if(v=f.alternate,v===null)throw Error(r(387));v.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(t!==null?t.push(Ss):t=[Ss])}f=f.return}t!==null&&bu(i,t,s,c),i.flags|=262144}function Uo(t){for(t=t.firstContext;t!==null;){if(!It(t.context._currentValue,t.memoizedValue))return!0;t=t.next}return!1}function sa(t){ra=t,Vn=null,t=t.dependencies,t!==null&&(t.firstContext=null)}function Ct(t){return Ep(ra,t)}function Lo(t,i){return ra===null&&sa(t),Ep(t,i)}function Ep(t,i){var s=i._currentValue;if(i={context:i,memoizedValue:s,next:null},Vn===null){if(t===null)throw Error(r(308));Vn=i,t.dependencies={lanes:0,firstContext:i},t.flags|=524288}else Vn=Vn.next=i;return s}var pi=!1;function Su(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Tu(t,i){t=t.updateQueue,i.updateQueue===t&&(i.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function gi(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function vi(t,i,s){var c=t.updateQueue;if(c===null)return null;if(c=c.shared,(Qe&2)!==0){var f=c.pending;return f===null?i.next=i:(i.next=f.next,f.next=i),c.pending=i,i=go(t),rm(t,null,s),i}return po(t,c,i,s),go(t)}function is(t,i,s){if(i=i.updateQueue,i!==null&&(i=i.shared,(s&4194176)!==0)){var c=i.lanes;c&=t.pendingLanes,s|=c,i.lanes=s,hh(t,s)}}function ku(t,i){var s=t.updateQueue,c=t.alternate;if(c!==null&&(c=c.updateQueue,s===c)){var f=null,p=null;if(s=s.firstBaseUpdate,s!==null){do{var v={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};p===null?f=p=v:p=p.next=v,s=s.next}while(s!==null);p===null?f=p=i:p=p.next=i}else f=p=i;s={baseState:c.baseState,firstBaseUpdate:f,lastBaseUpdate:p,shared:c.shared,callbacks:c.callbacks},t.updateQueue=s;return}t=s.lastBaseUpdate,t===null?s.firstBaseUpdate=i:t.next=i,s.lastBaseUpdate=i}var Cu=!1;function as(){if(Cu){var t=Va;if(t!==null)throw t}}function rs(t,i,s,c){Cu=!1;var f=t.updateQueue;pi=!1;var p=f.firstBaseUpdate,v=f.lastBaseUpdate,S=f.shared.pending;if(S!==null){f.shared.pending=null;var E=S,M=E.next;E.next=null,v===null?p=M:v.next=M,v=E;var q=t.alternate;q!==null&&(q=q.updateQueue,S=q.lastBaseUpdate,S!==v&&(S===null?q.firstBaseUpdate=M:S.next=M,q.lastBaseUpdate=E))}if(p!==null){var K=f.baseState;v=0,q=M=E=null,S=p;do{var L=S.lane&-536870913,z=L!==S.lane;if(z?(Ee&L)===L:(c&L)===L){L!==0&&L===qa&&(Cu=!0),q!==null&&(q=q.next={lane:0,tag:S.tag,payload:S.payload,callback:null,next:null});e:{var se=t,me=S;L=i;var Je=s;switch(me.tag){case 1:if(se=me.payload,typeof se=="function"){K=se.call(Je,K,L);break e}K=se;break e;case 3:se.flags=se.flags&-65537|128;case 0:if(se=me.payload,L=typeof se=="function"?se.call(Je,K,L):se,L==null)break e;K=J({},K,L);break e;case 2:pi=!0}}L=S.callback,L!==null&&(t.flags|=64,z&&(t.flags|=8192),z=f.callbacks,z===null?f.callbacks=[L]:z.push(L))}else z={lane:L,tag:S.tag,payload:S.payload,callback:S.callback,next:null},q===null?(M=q=z,E=K):q=q.next=z,v|=L;if(S=S.next,S===null){if(S=f.shared.pending,S===null)break;z=S,S=z.next,z.next=null,f.lastBaseUpdate=z,f.shared.pending=null}}while(!0);q===null&&(E=K),f.baseState=E,f.firstBaseUpdate=M,f.lastBaseUpdate=q,p===null&&(f.shared.lanes=0),ki|=v,t.lanes=v,t.memoizedState=K}}function Rp(t,i){if(typeof t!="function")throw Error(r(191,t));t.call(i)}function _p(t,i){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;t<s.length;t++)Rp(s[t],i)}function ss(t,i){try{var s=i.updateQueue,c=s!==null?s.lastEffect:null;if(c!==null){var f=c.next;s=f;do{if((s.tag&t)===t){c=void 0;var p=s.create,v=s.inst;c=p(),v.destroy=c}s=s.next}while(s!==f)}}catch(S){Le(i,i.return,S)}}function yi(t,i,s){try{var c=i.updateQueue,f=c!==null?c.lastEffect:null;if(f!==null){var p=f.next;c=p;do{if((c.tag&t)===t){var v=c.inst,S=v.destroy;if(S!==void 0){v.destroy=void 0,f=i;var E=s;try{S()}catch(M){Le(f,E,M)}}}c=c.next}while(c!==p)}}catch(M){Le(i,i.return,M)}}function wp(t){var i=t.updateQueue;if(i!==null){var s=t.stateNode;try{_p(i,s)}catch(c){Le(t,t.return,c)}}}function Op(t,i,s){s.props=aa(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(c){Le(t,i,c)}}function oa(t,i){try{var s=t.ref;if(s!==null){var c=t.stateNode;switch(t.tag){case 26:case 27:case 5:var f=c;break;default:f=c}typeof s=="function"?t.refCleanup=s(f):s.current=f}}catch(p){Le(t,i,p)}}function jt(t,i){var s=t.ref,c=t.refCleanup;if(s!==null)if(typeof c=="function")try{c()}catch(f){Le(t,i,f)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(f){Le(t,i,f)}else s.current=null}function Dp(t){var i=t.type,s=t.memoizedProps,c=t.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":s.autoFocus&&c.focus();break e;case"img":s.src?c.src=s.src:s.srcSet&&(c.srcset=s.srcSet)}}catch(f){Le(t,t.return,f)}}function Ap(t,i,s){try{var c=t.stateNode;YT(c,t.type,s,i),c[Ot]=i}catch(f){Le(t,t.return,f)}}function Mp(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27||t.tag===4}function Eu(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Mp(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==27&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Ru(t,i,s){var c=t.tag;if(c===5||c===6)t=t.stateNode,i?s.nodeType===8?s.parentNode.insertBefore(t,i):s.insertBefore(t,i):(s.nodeType===8?(i=s.parentNode,i.insertBefore(t,s)):(i=s,i.appendChild(t)),s=s._reactRootContainer,s!=null||i.onclick!==null||(i.onclick=Zo));else if(c!==4&&c!==27&&(t=t.child,t!==null))for(Ru(t,i,s),t=t.sibling;t!==null;)Ru(t,i,s),t=t.sibling}function Io(t,i,s){var c=t.tag;if(c===5||c===6)t=t.stateNode,i?s.insertBefore(t,i):s.appendChild(t);else if(c!==4&&c!==27&&(t=t.child,t!==null))for(Io(t,i,s),t=t.sibling;t!==null;)Io(t,i,s),t=t.sibling}var Gn=!1,Xe=!1,_u=!1,Pp=typeof WeakSet=="function"?WeakSet:Set,mt=null,xp=!1;function kT(t,i){if(t=t.containerInfo,ed=ic,t=Zh(t),Ol(t)){if("selectionStart"in t)var s={start:t.selectionStart,end:t.selectionEnd};else e:{s=(s=t.ownerDocument)&&s.defaultView||window;var c=s.getSelection&&s.getSelection();if(c&&c.rangeCount!==0){s=c.anchorNode;var f=c.anchorOffset,p=c.focusNode;c=c.focusOffset;try{s.nodeType,p.nodeType}catch{s=null;break e}var v=0,S=-1,E=-1,M=0,q=0,K=t,L=null;t:for(;;){for(var z;K!==s||f!==0&&K.nodeType!==3||(S=v+f),K!==p||c!==0&&K.nodeType!==3||(E=v+c),K.nodeType===3&&(v+=K.nodeValue.length),(z=K.firstChild)!==null;)L=K,K=z;for(;;){if(K===t)break t;if(L===s&&++M===f&&(S=v),L===p&&++q===c&&(E=v),(z=K.nextSibling)!==null)break;K=L,L=K.parentNode}K=z}s=S===-1||E===-1?null:{start:S,end:E}}else s=null}s=s||{start:0,end:0}}else s=null;for(td={focusedElem:t,selectionRange:s},ic=!1,mt=i;mt!==null;)if(i=mt,t=i.child,(i.subtreeFlags&1028)!==0&&t!==null)t.return=i,mt=t;else for(;mt!==null;){switch(i=mt,p=i.alternate,t=i.flags,i.tag){case 0:break;case 11:case 15:break;case 1:if((t&1024)!==0&&p!==null){t=void 0,s=i,f=p.memoizedProps,p=p.memoizedState,c=s.stateNode;try{var se=aa(s.type,f,s.elementType===s.type);t=c.getSnapshotBeforeUpdate(se,p),c.__reactInternalSnapshotBeforeUpdate=t}catch(me){Le(s,s.return,me)}}break;case 3:if((t&1024)!==0){if(t=i.stateNode.containerInfo,s=t.nodeType,s===9)rd(t);else if(s===1)switch(t.nodeName){case"HEAD":case"HTML":case"BODY":rd(t);break;default:t.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((t&1024)!==0)throw Error(r(163))}if(t=i.sibling,t!==null){t.return=i.return,mt=t;break}mt=i.return}return se=xp,xp=!1,se}function Np(t,i,s){var c=s.flags;switch(s.tag){case 0:case 11:case 15:Yn(t,s),c&4&&ss(5,s);break;case 1:if(Yn(t,s),c&4)if(t=s.stateNode,i===null)try{t.componentDidMount()}catch(S){Le(s,s.return,S)}else{var f=aa(s.type,i.memoizedProps);i=i.memoizedState;try{t.componentDidUpdate(f,i,t.__reactInternalSnapshotBeforeUpdate)}catch(S){Le(s,s.return,S)}}c&64&&wp(s),c&512&&oa(s,s.return);break;case 3:if(Yn(t,s),c&64&&(c=s.updateQueue,c!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{_p(c,t)}catch(S){Le(s,s.return,S)}}break;case 26:Yn(t,s),c&512&&oa(s,s.return);break;case 27:case 5:Yn(t,s),i===null&&c&4&&Dp(s),c&512&&oa(s,s.return);break;case 12:Yn(t,s);break;case 13:Yn(t,s),c&4&&Ip(t,s);break;case 22:if(f=s.memoizedState!==null||Gn,!f){i=i!==null&&i.memoizedState!==null||Xe;var p=Gn,v=Xe;Gn=f,(Xe=i)&&!v?bi(t,s,(s.subtreeFlags&8772)!==0):Yn(t,s),Gn=p,Xe=v}c&512&&(s.memoizedProps.mode==="manual"?oa(s,s.return):jt(s,s.return));break;default:Yn(t,s)}}function Up(t){var i=t.alternate;i!==null&&(t.alternate=null,Up(i)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(i=t.stateNode,i!==null&&fl(i)),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}var st=null,Bt=!1;function Fn(t,i,s){for(s=s.child;s!==null;)Lp(t,i,s),s=s.sibling}function Lp(t,i,s){if(Ut&&typeof Ut.onCommitFiberUnmount=="function")try{Ut.onCommitFiberUnmount(Dr,s)}catch{}switch(s.tag){case 26:Xe||jt(s,i),Fn(t,i,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:Xe||jt(s,i);var c=st,f=Bt;for(st=s.stateNode,Fn(t,i,s),s=s.stateNode,i=s.attributes;i.length;)s.removeAttributeNode(i[0]);fl(s),st=c,Bt=f;break;case 5:Xe||jt(s,i);case 6:f=st;var p=Bt;if(st=null,Fn(t,i,s),st=f,Bt=p,st!==null)if(Bt)try{t=st,c=s.stateNode,t.nodeType===8?t.parentNode.removeChild(c):t.removeChild(c)}catch(v){Le(s,i,v)}else try{st.removeChild(s.stateNode)}catch(v){Le(s,i,v)}break;case 18:st!==null&&(Bt?(i=st,s=s.stateNode,i.nodeType===8?ad(i.parentNode,s):i.nodeType===1&&ad(i,s),Es(i)):ad(st,s.stateNode));break;case 4:c=st,f=Bt,st=s.stateNode.containerInfo,Bt=!0,Fn(t,i,s),st=c,Bt=f;break;case 0:case 11:case 14:case 15:Xe||yi(2,s,i),Xe||yi(4,s,i),Fn(t,i,s);break;case 1:Xe||(jt(s,i),c=s.stateNode,typeof c.componentWillUnmount=="function"&&Op(s,i,c)),Fn(t,i,s);break;case 21:Fn(t,i,s);break;case 22:Xe||jt(s,i),Xe=(c=Xe)||s.memoizedState!==null,Fn(t,i,s),Xe=c;break;default:Fn(t,i,s)}}function Ip(t,i){if(i.memoizedState===null&&(t=i.alternate,t!==null&&(t=t.memoizedState,t!==null&&(t=t.dehydrated,t!==null))))try{Es(t)}catch(s){Le(i,i.return,s)}}function CT(t){switch(t.tag){case 13:case 19:var i=t.stateNode;return i===null&&(i=t.stateNode=new Pp),i;case 22:return t=t.stateNode,i=t._retryCache,i===null&&(i=t._retryCache=new Pp),i;default:throw Error(r(435,t.tag))}}function wu(t,i){var s=CT(t);i.forEach(function(c){var f=LT.bind(null,t,c);s.has(c)||(s.add(c),c.then(f,f))})}function $t(t,i){var s=i.deletions;if(s!==null)for(var c=0;c<s.length;c++){var f=s[c],p=t,v=i,S=v;e:for(;S!==null;){switch(S.tag){case 27:case 5:st=S.stateNode,Bt=!1;break e;case 3:st=S.stateNode.containerInfo,Bt=!0;break e;case 4:st=S.stateNode.containerInfo,Bt=!0;break e}S=S.return}if(st===null)throw Error(r(160));Lp(p,v,f),st=null,Bt=!1,p=f.alternate,p!==null&&(p.return=null),f.return=null}if(i.subtreeFlags&13878)for(i=i.child;i!==null;)jp(i,t),i=i.sibling}var cn=null;function jp(t,i){var s=t.alternate,c=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:$t(i,t),en(t),c&4&&(yi(3,t,t.return),ss(3,t),yi(5,t,t.return));break;case 1:$t(i,t),en(t),c&512&&(Xe||s===null||jt(s,s.return)),c&64&&Gn&&(t=t.updateQueue,t!==null&&(c=t.callbacks,c!==null&&(s=t.shared.hiddenCallbacks,t.shared.hiddenCallbacks=s===null?c:s.concat(c))));break;case 26:var f=cn;if($t(i,t),en(t),c&512&&(Xe||s===null||jt(s,s.return)),c&4){var p=s!==null?s.memoizedState:null;if(c=t.memoizedState,s===null)if(c===null)if(t.stateNode===null){e:{c=t.type,s=t.memoizedProps,f=f.ownerDocument||f;t:switch(c){case"title":p=f.getElementsByTagName("title")[0],(!p||p[Pr]||p[kt]||p.namespaceURI==="http://www.w3.org/2000/svg"||p.hasAttribute("itemprop"))&&(p=f.createElement(c),f.head.insertBefore(p,f.querySelector("head > title"))),St(p,c,s),p[kt]=t,ft(p),c=p;break e;case"link":var v=Dg("link","href",f).get(c+(s.href||""));if(v){for(var S=0;S<v.length;S++)if(p=v[S],p.getAttribute("href")===(s.href==null?null:s.href)&&p.getAttribute("rel")===(s.rel==null?null:s.rel)&&p.getAttribute("title")===(s.title==null?null:s.title)&&p.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){v.splice(S,1);break t}}p=f.createElement(c),St(p,c,s),f.head.appendChild(p);break;case"meta":if(v=Dg("meta","content",f).get(c+(s.content||""))){for(S=0;S<v.length;S++)if(p=v[S],p.getAttribute("content")===(s.content==null?null:""+s.content)&&p.getAttribute("name")===(s.name==null?null:s.name)&&p.getAttribute("property")===(s.property==null?null:s.property)&&p.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&p.getAttribute("charset")===(s.charSet==null?null:s.charSet)){v.splice(S,1);break t}}p=f.createElement(c),St(p,c,s),f.head.appendChild(p);break;default:throw Error(r(468,c))}p[kt]=t,ft(p),c=p}t.stateNode=c}else Ag(f,t.type,t.stateNode);else t.stateNode=Og(f,c,t.memoizedProps);else p!==c?(p===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):p.count--,c===null?Ag(f,t.type,t.stateNode):Og(f,c,t.memoizedProps)):c===null&&t.stateNode!==null&&Ap(t,t.memoizedProps,s.memoizedProps)}break;case 27:if(c&4&&t.alternate===null){f=t.stateNode,p=t.memoizedProps;try{for(var E=f.firstChild;E;){var M=E.nextSibling,q=E.nodeName;E[Pr]||q==="HEAD"||q==="BODY"||q==="SCRIPT"||q==="STYLE"||q==="LINK"&&E.rel.toLowerCase()==="stylesheet"||f.removeChild(E),E=M}for(var K=t.type,L=f.attributes;L.length;)f.removeAttributeNode(L[0]);St(f,K,p),f[kt]=t,f[Ot]=p}catch(se){Le(t,t.return,se)}}case 5:if($t(i,t),en(t),c&512&&(Xe||s===null||jt(s,s.return)),t.flags&32){f=t.stateNode;try{Da(f,"")}catch(se){Le(t,t.return,se)}}c&4&&t.stateNode!=null&&(f=t.memoizedProps,Ap(t,f,s!==null?s.memoizedProps:f)),c&1024&&(_u=!0);break;case 6:if($t(i,t),en(t),c&4){if(t.stateNode===null)throw Error(r(162));c=t.memoizedProps,s=t.stateNode;try{s.nodeValue=c}catch(se){Le(t,t.return,se)}}break;case 3:if(ec=null,f=cn,cn=Wo(i.containerInfo),$t(i,t),cn=f,en(t),c&4&&s!==null&&s.memoizedState.isDehydrated)try{Es(i.containerInfo)}catch(se){Le(t,t.return,se)}_u&&(_u=!1,Bp(t));break;case 4:c=cn,cn=Wo(t.stateNode.containerInfo),$t(i,t),en(t),cn=c;break;case 12:$t(i,t),en(t);break;case 13:$t(i,t),en(t),t.child.flags&8192&&t.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Lu=Sn()),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,wu(t,c)));break;case 22:if(c&512&&(Xe||s===null||jt(s,s.return)),E=t.memoizedState!==null,M=s!==null&&s.memoizedState!==null,q=Gn,K=Xe,Gn=q||E,Xe=K||M,$t(i,t),Xe=K,Gn=q,en(t),i=t.stateNode,i._current=t,i._visibility&=-3,i._visibility|=i._pendingVisibility&2,c&8192&&(i._visibility=E?i._visibility&-2:i._visibility|1,E&&(i=Gn||Xe,s===null||M||i||Ya(t)),t.memoizedProps===null||t.memoizedProps.mode!=="manual"))e:for(s=null,i=t;;){if(i.tag===5||i.tag===26||i.tag===27){if(s===null){M=s=i;try{if(f=M.stateNode,E)p=f.style,typeof p.setProperty=="function"?p.setProperty("display","none","important"):p.display="none";else{v=M.stateNode,S=M.memoizedProps.style;var z=S!=null&&S.hasOwnProperty("display")?S.display:null;v.style.display=z==null||typeof z=="boolean"?"":(""+z).trim()}}catch(se){Le(M,M.return,se)}}}else if(i.tag===6){if(s===null){M=i;try{M.stateNode.nodeValue=E?"":M.memoizedProps}catch(se){Le(M,M.return,se)}}}else if((i.tag!==22&&i.tag!==23||i.memoizedState===null||i===t)&&i.child!==null){i.child.return=i,i=i.child;continue}if(i===t)break e;for(;i.sibling===null;){if(i.return===null||i.return===t)break e;s===i&&(s=null),i=i.return}s===i&&(s=null),i.sibling.return=i.return,i=i.sibling}c&4&&(c=t.updateQueue,c!==null&&(s=c.retryQueue,s!==null&&(c.retryQueue=null,wu(t,s))));break;case 19:$t(i,t),en(t),c&4&&(c=t.updateQueue,c!==null&&(t.updateQueue=null,wu(t,c)));break;case 21:break;default:$t(i,t),en(t)}}function en(t){var i=t.flags;if(i&2){try{if(t.tag!==27){e:{for(var s=t.return;s!==null;){if(Mp(s)){var c=s;break e}s=s.return}throw Error(r(160))}switch(c.tag){case 27:var f=c.stateNode,p=Eu(t);Io(t,p,f);break;case 5:var v=c.stateNode;c.flags&32&&(Da(v,""),c.flags&=-33);var S=Eu(t);Io(t,S,v);break;case 3:case 4:var E=c.stateNode.containerInfo,M=Eu(t);Ru(t,M,E);break;default:throw Error(r(161))}}}catch(q){Le(t,t.return,q)}t.flags&=-3}i&4096&&(t.flags&=-4097)}function Bp(t){if(t.subtreeFlags&1024)for(t=t.child;t!==null;){var i=t;Bp(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),t=t.sibling}}function Yn(t,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)Np(t,i.alternate,i),i=i.sibling}function Ya(t){for(t=t.child;t!==null;){var i=t;switch(i.tag){case 0:case 11:case 14:case 15:yi(4,i,i.return),Ya(i);break;case 1:jt(i,i.return);var s=i.stateNode;typeof s.componentWillUnmount=="function"&&Op(i,i.return,s),Ya(i);break;case 26:case 27:case 5:jt(i,i.return),Ya(i);break;case 22:jt(i,i.return),i.memoizedState===null&&Ya(i);break;default:Ya(i)}t=t.sibling}}function bi(t,i,s){for(s=s&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var c=i.alternate,f=t,p=i,v=p.flags;switch(p.tag){case 0:case 11:case 15:bi(f,p,s),ss(4,p);break;case 1:if(bi(f,p,s),c=p,f=c.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(M){Le(c,c.return,M)}if(c=p,f=c.updateQueue,f!==null){var S=c.stateNode;try{var E=f.shared.hiddenCallbacks;if(E!==null)for(f.shared.hiddenCallbacks=null,f=0;f<E.length;f++)Rp(E[f],S)}catch(M){Le(c,c.return,M)}}s&&v&64&&wp(p),oa(p,p.return);break;case 26:case 27:case 5:bi(f,p,s),s&&c===null&&v&4&&Dp(p),oa(p,p.return);break;case 12:bi(f,p,s);break;case 13:bi(f,p,s),s&&v&4&&Ip(f,p);break;case 22:p.memoizedState===null&&bi(f,p,s),oa(p,p.return);break;default:bi(f,p,s)}i=i.sibling}}function Ou(t,i){var s=null;t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),t=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(t=i.memoizedState.cachePool.pool),t!==s&&(t!=null&&t.refCount++,s!=null&&Zr(s))}function Du(t,i){t=null,i.alternate!==null&&(t=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==t&&(i.refCount++,t!=null&&Zr(t))}function Si(t,i,s,c){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)zp(t,i,s,c),i=i.sibling}function zp(t,i,s,c){var f=i.flags;switch(i.tag){case 0:case 11:case 15:Si(t,i,s,c),f&2048&&ss(9,i);break;case 3:Si(t,i,s,c),f&2048&&(t=null,i.alternate!==null&&(t=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==t&&(i.refCount++,t!=null&&Zr(t)));break;case 12:if(f&2048){Si(t,i,s,c),t=i.stateNode;try{var p=i.memoizedProps,v=p.id,S=p.onPostCommit;typeof S=="function"&&S(v,i.alternate===null?"mount":"update",t.passiveEffectDuration,-0)}catch(E){Le(i,i.return,E)}}else Si(t,i,s,c);break;case 23:break;case 22:p=i.stateNode,i.memoizedState!==null?p._visibility&4?Si(t,i,s,c):os(t,i):p._visibility&4?Si(t,i,s,c):(p._visibility|=4,Ka(t,i,s,c,(i.subtreeFlags&10256)!==0)),f&2048&&Ou(i.alternate,i);break;case 24:Si(t,i,s,c),f&2048&&Du(i.alternate,i);break;default:Si(t,i,s,c)}}function Ka(t,i,s,c,f){for(f=f&&(i.subtreeFlags&10256)!==0,i=i.child;i!==null;){var p=t,v=i,S=s,E=c,M=v.flags;switch(v.tag){case 0:case 11:case 15:Ka(p,v,S,E,f),ss(8,v);break;case 23:break;case 22:var q=v.stateNode;v.memoizedState!==null?q._visibility&4?Ka(p,v,S,E,f):os(p,v):(q._visibility|=4,Ka(p,v,S,E,f)),f&&M&2048&&Ou(v.alternate,v);break;case 24:Ka(p,v,S,E,f),f&&M&2048&&Du(v.alternate,v);break;default:Ka(p,v,S,E,f)}i=i.sibling}}function os(t,i){if(i.subtreeFlags&10256)for(i=i.child;i!==null;){var s=t,c=i,f=c.flags;switch(c.tag){case 22:os(s,c),f&2048&&Ou(c.alternate,c);break;case 24:os(s,c),f&2048&&Du(c.alternate,c);break;default:os(s,c)}i=i.sibling}}var cs=8192;function Qa(t){if(t.subtreeFlags&cs)for(t=t.child;t!==null;)qp(t),t=t.sibling}function qp(t){switch(t.tag){case 26:Qa(t),t.flags&cs&&t.memoizedState!==null&&dk(cn,t.memoizedState,t.memoizedProps);break;case 5:Qa(t);break;case 3:case 4:var i=cn;cn=Wo(t.stateNode.containerInfo),Qa(t),cn=i;break;case 22:t.memoizedState===null&&(i=t.alternate,i!==null&&i.memoizedState!==null?(i=cs,cs=16777216,Qa(t),cs=i):Qa(t));break;default:Qa(t)}}function Vp(t){var i=t.alternate;if(i!==null&&(t=i.child,t!==null)){i.child=null;do i=t.sibling,t.sibling=null,t=i;while(t!==null)}}function ls(t){var i=t.deletions;if((t.flags&16)!==0){if(i!==null)for(var s=0;s<i.length;s++){var c=i[s];mt=c,Gp(c,t)}Vp(t)}if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Hp(t),t=t.sibling}function Hp(t){switch(t.tag){case 0:case 11:case 15:ls(t),t.flags&2048&&yi(9,t,t.return);break;case 3:ls(t);break;case 12:ls(t);break;case 22:var i=t.stateNode;t.memoizedState!==null&&i._visibility&4&&(t.return===null||t.return.tag!==13)?(i._visibility&=-5,jo(t)):ls(t);break;default:ls(t)}}function jo(t){var i=t.deletions;if((t.flags&16)!==0){if(i!==null)for(var s=0;s<i.length;s++){var c=i[s];mt=c,Gp(c,t)}Vp(t)}for(t=t.child;t!==null;){switch(i=t,i.tag){case 0:case 11:case 15:yi(8,i,i.return),jo(i);break;case 22:s=i.stateNode,s._visibility&4&&(s._visibility&=-5,jo(i));break;default:jo(i)}t=t.sibling}}function Gp(t,i){for(;mt!==null;){var s=mt;switch(s.tag){case 0:case 11:case 15:yi(8,s,i);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var c=s.memoizedState.cachePool.pool;c!=null&&c.refCount++}break;case 24:Zr(s.memoizedState.cache)}if(c=s.child,c!==null)c.return=s,mt=c;else e:for(s=t;mt!==null;){c=mt;var f=c.sibling,p=c.return;if(Up(c),c===s){mt=null;break e}if(f!==null){f.return=p,mt=f;break e}mt=p}}}function ET(t,i,s,c){this.tag=t,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=c,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tn(t,i,s,c){return new ET(t,i,s,c)}function Au(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Ti(t,i){var s=t.alternate;return s===null?(s=tn(t.tag,i,t.key,t.mode),s.elementType=t.elementType,s.type=t.type,s.stateNode=t.stateNode,s.alternate=t,t.alternate=s):(s.pendingProps=i,s.type=t.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=t.flags&31457280,s.childLanes=t.childLanes,s.lanes=t.lanes,s.child=t.child,s.memoizedProps=t.memoizedProps,s.memoizedState=t.memoizedState,s.updateQueue=t.updateQueue,i=t.dependencies,s.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},s.sibling=t.sibling,s.index=t.index,s.ref=t.ref,s.refCleanup=t.refCleanup,s}function Fp(t,i){t.flags&=31457282;var s=t.alternate;return s===null?(t.childLanes=0,t.lanes=i,t.child=null,t.subtreeFlags=0,t.memoizedProps=null,t.memoizedState=null,t.updateQueue=null,t.dependencies=null,t.stateNode=null):(t.childLanes=s.childLanes,t.lanes=s.lanes,t.child=s.child,t.subtreeFlags=0,t.deletions=null,t.memoizedProps=s.memoizedProps,t.memoizedState=s.memoizedState,t.updateQueue=s.updateQueue,t.type=s.type,i=s.dependencies,t.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),t}function Bo(t,i,s,c,f,p){var v=0;if(c=t,typeof t=="function")Au(t)&&(v=1);else if(typeof t=="string")v=lk(t,s,bn.current)?26:t==="html"||t==="head"||t==="body"?27:5;else e:switch(t){case h:return ca(s.children,f,p,i);case m:v=8,f|=24;break;case g:return t=tn(12,s,i,f|2),t.elementType=g,t.lanes=p,t;case k:return t=tn(13,s,i,f),t.elementType=k,t.lanes=p,t;case w:return t=tn(19,s,i,f),t.elementType=w,t.lanes=p,t;case Q:return Yp(s,f,p,i);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case y:case T:v=10;break e;case b:v=9;break e;case C:v=11;break e;case O:v=14;break e;case V:v=16,c=null;break e}v=29,s=Error(r(130,t===null?"null":typeof t,"")),c=null}return i=tn(v,s,i,f),i.elementType=t,i.type=c,i.lanes=p,i}function ca(t,i,s,c){return t=tn(7,t,c,i),t.lanes=s,t}function Yp(t,i,s,c){t=tn(22,t,c,i),t.elementType=Q,t.lanes=s;var f={_visibility:1,_pendingVisibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null,_current:null,detach:function(){var p=f._current;if(p===null)throw Error(r(456));if((f._pendingVisibility&2)===0){var v=li(p,2);v!==null&&(f._pendingVisibility|=2,wt(v,p,2))}},attach:function(){var p=f._current;if(p===null)throw Error(r(456));if((f._pendingVisibility&2)!==0){var v=li(p,2);v!==null&&(f._pendingVisibility&=-3,wt(v,p,2))}}};return t.stateNode=f,t}function Mu(t,i,s){return t=tn(6,t,null,i),t.lanes=s,t}function Pu(t,i,s){return i=tn(4,t.children!==null?t.children:[],t.key,i),i.lanes=s,i.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},i}function Kn(t){t.flags|=4}function Kp(t,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)t.flags&=-16777217;else if(t.flags|=16777216,!Mg(i)){if(i=Wt.current,i!==null&&((Ee&4194176)===Ee?kn!==null:(Ee&62914560)!==Ee&&(Ee&536870912)===0||i!==kn))throw Kr=Il,um;t.flags|=8192}}function zo(t,i){i!==null&&(t.flags|=4),t.flags&16384&&(i=t.tag!==22?dh():536870912,t.lanes|=i,Za|=i)}function us(t,i){if(!we)switch(t.tailMode){case"hidden":i=t.tail;for(var s=null;i!==null;)i.alternate!==null&&(s=i),i=i.sibling;s===null?t.tail=null:s.sibling=null;break;case"collapsed":s=t.tail;for(var c=null;s!==null;)s.alternate!==null&&(c=s),s=s.sibling;c===null?i||t.tail===null?t.tail=null:t.tail.sibling=null:c.sibling=null}}function Ke(t){var i=t.alternate!==null&&t.alternate.child===t.child,s=0,c=0;if(i)for(var f=t.child;f!==null;)s|=f.lanes|f.childLanes,c|=f.subtreeFlags&31457280,c|=f.flags&31457280,f.return=t,f=f.sibling;else for(f=t.child;f!==null;)s|=f.lanes|f.childLanes,c|=f.subtreeFlags,c|=f.flags,f.return=t,f=f.sibling;return t.subtreeFlags|=c,t.childLanes=s,i}function RT(t,i,s){var c=i.pendingProps;switch(Ul(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ke(i),null;case 1:return Ke(i),null;case 3:return s=i.stateNode,c=null,t!==null&&(c=t.memoizedState.cache),i.memoizedState.cache!==c&&(i.flags|=2048),Hn(lt),Ca(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(t===null||t.child===null)&&(Hr(i)?Kn(i):t===null||t.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,on!==null&&(zu(on),on=null))),Ke(i),null;case 26:return s=i.memoizedState,t===null?(Kn(i),s!==null?(Ke(i),Kp(i,s)):(Ke(i),i.flags&=-16777217)):s?s!==t.memoizedState?(Kn(i),Ke(i),Kp(i,s)):(Ke(i),i.flags&=-16777217):(t.memoizedProps!==c&&Kn(i),Ke(i),i.flags&=-16777217),null;case 27:Js(i),s=ri.current;var f=i.type;if(t!==null&&i.stateNode!=null)t.memoizedProps!==c&&Kn(i);else{if(!c){if(i.stateNode===null)throw Error(r(166));return Ke(i),null}t=bn.current,Hr(i)?cm(i):(t=Cg(f,c,s),i.stateNode=t,Kn(i))}return Ke(i),null;case 5:if(Js(i),s=i.type,t!==null&&i.stateNode!=null)t.memoizedProps!==c&&Kn(i);else{if(!c){if(i.stateNode===null)throw Error(r(166));return Ke(i),null}if(t=bn.current,Hr(i))cm(i);else{switch(f=Jo(ri.current),t){case 1:t=f.createElementNS("http://www.w3.org/2000/svg",s);break;case 2:t=f.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;default:switch(s){case"svg":t=f.createElementNS("http://www.w3.org/2000/svg",s);break;case"math":t=f.createElementNS("http://www.w3.org/1998/Math/MathML",s);break;case"script":t=f.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild);break;case"select":t=typeof c.is=="string"?f.createElement("select",{is:c.is}):f.createElement("select"),c.multiple?t.multiple=!0:c.size&&(t.size=c.size);break;default:t=typeof c.is=="string"?f.createElement(s,{is:c.is}):f.createElement(s)}}t[kt]=i,t[Ot]=c;e:for(f=i.child;f!==null;){if(f.tag===5||f.tag===6)t.appendChild(f.stateNode);else if(f.tag!==4&&f.tag!==27&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===i)break e;for(;f.sibling===null;){if(f.return===null||f.return===i)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}i.stateNode=t;e:switch(St(t,s,c),s){case"button":case"input":case"select":case"textarea":t=!!c.autoFocus;break e;case"img":t=!0;break e;default:t=!1}t&&Kn(i)}}return Ke(i),i.flags&=-16777217,null;case 6:if(t&&i.stateNode!=null)t.memoizedProps!==c&&Kn(i);else{if(typeof c!="string"&&i.stateNode===null)throw Error(r(166));if(t=ri.current,Hr(i)){if(t=i.stateNode,s=i.memoizedProps,c=null,f=_t,f!==null)switch(f.tag){case 27:case 5:c=f.memoizedProps}t[kt]=i,t=!!(t.nodeValue===s||c!==null&&c.suppressHydrationWarning===!0||vg(t.nodeValue,s)),t||Wi(i)}else t=Jo(t).createTextNode(c),t[kt]=i,i.stateNode=t}return Ke(i),null;case 13:if(c=i.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(f=Hr(i),c!==null&&c.dehydrated!==null){if(t===null){if(!f)throw Error(r(318));if(f=i.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));f[kt]=i}else Gr(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Ke(i),f=!1}else on!==null&&(zu(on),on=null),f=!0;if(!f)return i.flags&256?(Bn(i),i):(Bn(i),null)}if(Bn(i),(i.flags&128)!==0)return i.lanes=s,i;if(s=c!==null,t=t!==null&&t.memoizedState!==null,s){c=i.child,f=null,c.alternate!==null&&c.alternate.memoizedState!==null&&c.alternate.memoizedState.cachePool!==null&&(f=c.alternate.memoizedState.cachePool.pool);var p=null;c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(p=c.memoizedState.cachePool.pool),p!==f&&(c.flags|=2048)}return s!==t&&s&&(i.child.flags|=8192),zo(i,i.updateQueue),Ke(i),null;case 4:return Ca(),t===null&&Ju(i.stateNode.containerInfo),Ke(i),null;case 10:return Hn(i.type),Ke(i),null;case 19:if(it(ct),f=i.memoizedState,f===null)return Ke(i),null;if(c=(i.flags&128)!==0,p=f.rendering,p===null)if(c)us(f,!1);else{if(Ze!==0||t!==null&&(t.flags&128)!==0)for(t=i.child;t!==null;){if(p=Co(t),p!==null){for(i.flags|=128,us(f,!1),t=p.updateQueue,i.updateQueue=t,zo(i,t),i.subtreeFlags=0,t=s,s=i.child;s!==null;)Fp(s,t),s=s.sibling;return Ve(ct,ct.current&1|2),i.child}t=t.sibling}f.tail!==null&&Sn()>qo&&(i.flags|=128,c=!0,us(f,!1),i.lanes=4194304)}else{if(!c)if(t=Co(p),t!==null){if(i.flags|=128,c=!0,t=t.updateQueue,i.updateQueue=t,zo(i,t),us(f,!0),f.tail===null&&f.tailMode==="hidden"&&!p.alternate&&!we)return Ke(i),null}else 2*Sn()-f.renderingStartTime>qo&&s!==536870912&&(i.flags|=128,c=!0,us(f,!1),i.lanes=4194304);f.isBackwards?(p.sibling=i.child,i.child=p):(t=f.last,t!==null?t.sibling=p:i.child=p,f.last=p)}return f.tail!==null?(i=f.tail,f.rendering=i,f.tail=i.sibling,f.renderingStartTime=Sn(),i.sibling=null,t=ct.current,Ve(ct,c?t&1|2:t&1),i):(Ke(i),null);case 22:case 23:return Bn(i),Bl(),c=i.memoizedState!==null,t!==null?t.memoizedState!==null!==c&&(i.flags|=8192):c&&(i.flags|=8192),c?(s&536870912)!==0&&(i.flags&128)===0&&(Ke(i),i.subtreeFlags&6&&(i.flags|=8192)):Ke(i),s=i.updateQueue,s!==null&&zo(i,s.retryQueue),s=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),c=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(c=i.memoizedState.cachePool.pool),c!==s&&(i.flags|=2048),t!==null&&it(ea),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),i.memoizedState.cache!==s&&(i.flags|=2048),Hn(lt),Ke(i),null;case 25:return null}throw Error(r(156,i.tag))}function _T(t,i){switch(Ul(i),i.tag){case 1:return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 3:return Hn(lt),Ca(),t=i.flags,(t&65536)!==0&&(t&128)===0?(i.flags=t&-65537|128,i):null;case 26:case 27:case 5:return Js(i),null;case 13:if(Bn(i),t=i.memoizedState,t!==null&&t.dehydrated!==null){if(i.alternate===null)throw Error(r(340));Gr()}return t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 19:return it(ct),null;case 4:return Ca(),null;case 10:return Hn(i.type),null;case 22:case 23:return Bn(i),Bl(),t!==null&&it(ea),t=i.flags,t&65536?(i.flags=t&-65537|128,i):null;case 24:return Hn(lt),null;case 25:return null;default:return null}}function Qp(t,i){switch(Ul(i),i.tag){case 3:Hn(lt),Ca();break;case 26:case 27:case 5:Js(i);break;case 4:Ca();break;case 13:Bn(i);break;case 19:it(ct);break;case 10:Hn(i.type);break;case 22:case 23:Bn(i),Bl(),t!==null&&it(ea);break;case 24:Hn(lt)}}var wT={getCacheForType:function(t){var i=Ct(lt),s=i.data.get(t);return s===void 0&&(s=t(),i.data.set(t,s)),s}},OT=typeof WeakMap=="function"?WeakMap:Map,Qe=0,Be=null,be=null,Ee=0,ze=0,zt=null,Qn=!1,Xa=!1,xu=!1,Xn=0,Ze=0,ki=0,la=0,Nu=0,nn=0,Za=0,ds=null,En=null,Uu=!1,Lu=0,qo=1/0,Vo=null,Ci=null,Ho=!1,ua=null,fs=0,Iu=0,ju=null,hs=0,Bu=null;function qt(){if((Qe&2)!==0&&Ee!==0)return Ee&-Ee;if(X.T!==null){var t=qa;return t!==0?t:Ku()}return ph()}function Xp(){nn===0&&(nn=(Ee&536870912)===0||we?uh():536870912);var t=Wt.current;return t!==null&&(t.flags|=32),nn}function wt(t,i,s){(t===Be&&ze===2||t.cancelPendingCommit!==null)&&(Ja(t,0),Zn(t,Ee,nn,!1)),Mr(t,s),((Qe&2)===0||t!==Be)&&(t===Be&&((Qe&2)===0&&(la|=s),Ze===4&&Zn(t,Ee,nn,!1)),Rn(t))}function Zp(t,i,s){if((Qe&6)!==0)throw Error(r(327));var c=!s&&(i&60)===0&&(i&t.expiredLanes)===0||Ar(t,i),f=c?MT(t,i):Hu(t,i,!0),p=c;do{if(f===0){Xa&&!c&&Zn(t,i,0,!1);break}else if(f===6)Zn(t,i,0,!Qn);else{if(s=t.current.alternate,p&&!DT(s)){f=Hu(t,i,!1),p=!1;continue}if(f===2){if(p=i,t.errorRecoveryDisabledLanes&p)var v=0;else v=t.pendingLanes&-536870913,v=v!==0?v:v&536870912?536870912:0;if(v!==0){i=v;e:{var S=t;f=ds;var E=S.current.memoizedState.isDehydrated;if(E&&(Ja(S,v).flags|=256),v=Hu(S,v,!1),v!==2){if(xu&&!E){S.errorRecoveryDisabledLanes|=p,la|=p,f=4;break e}p=En,En=f,p!==null&&zu(p)}f=v}if(p=!1,f!==2)continue}}if(f===1){Ja(t,0),Zn(t,i,0,!0);break}e:{switch(c=t,f){case 0:case 1:throw Error(r(345));case 4:if((i&4194176)===i){Zn(c,i,nn,!Qn);break e}break;case 2:En=null;break;case 3:case 5:break;default:throw Error(r(329))}if(c.finishedWork=s,c.finishedLanes=i,(i&62914560)===i&&(p=Lu+300-Sn(),10<p)){if(Zn(c,i,nn,!Qn),to(c,0)!==0)break e;c.timeoutHandle=Sg(Jp.bind(null,c,s,En,Vo,Uu,i,nn,la,Za,Qn,2,-0,0),p);break e}Jp(c,s,En,Vo,Uu,i,nn,la,Za,Qn,0,-0,0)}}break}while(!0);Rn(t)}function zu(t){En===null?En=t:En.push.apply(En,t)}function Jp(t,i,s,c,f,p,v,S,E,M,q,K,L){var z=i.subtreeFlags;if((z&8192||(z&16785408)===16785408)&&(bs={stylesheets:null,count:0,unsuspend:uk},qp(i),i=fk(),i!==null)){t.cancelPendingCommit=i(ag.bind(null,t,s,c,f,v,S,E,1,K,L)),Zn(t,p,v,!M);return}ag(t,s,c,f,v,S,E,q,K,L)}function DT(t){for(var i=t;;){var s=i.tag;if((s===0||s===11||s===15)&&i.flags&16384&&(s=i.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var c=0;c<s.length;c++){var f=s[c],p=f.getSnapshot;f=f.value;try{if(!It(p(),f))return!1}catch{return!1}}if(s=i.child,i.subtreeFlags&16384&&s!==null)s.return=i,i=s;else{if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function Zn(t,i,s,c){i&=~Nu,i&=~la,t.suspendedLanes|=i,t.pingedLanes&=~i,c&&(t.warmLanes|=i),c=t.expirationTimes;for(var f=i;0<f;){var p=31-Lt(f),v=1<<p;c[p]=-1,f&=~v}s!==0&&fh(t,s,i)}function Go(){return(Qe&6)===0?(ms(0),!1):!0}function qu(){if(be!==null){if(ze===0)var t=be.return;else t=be,Vn=ra=null,Kl(t),Ba=null,Qr=0,t=be;for(;t!==null;)Qp(t.alternate,t),t=t.return;be=null}}function Ja(t,i){t.finishedWork=null,t.finishedLanes=0;var s=t.timeoutHandle;s!==-1&&(t.timeoutHandle=-1,QT(s)),s=t.cancelPendingCommit,s!==null&&(t.cancelPendingCommit=null,s()),qu(),Be=t,be=s=Ti(t.current,null),Ee=i,ze=0,zt=null,Qn=!1,Xa=Ar(t,i),xu=!1,Za=nn=Nu=la=ki=Ze=0,En=ds=null,Uu=!1,(i&8)!==0&&(i|=i&32);var c=t.entangledLanes;if(c!==0)for(t=t.entanglements,c&=i;0<c;){var f=31-Lt(c),p=1<<f;i|=t[f],c&=~p}return Xn=i,mo(),s}function Wp(t,i){ve=null,X.H=Cn,i===Yr?(i=hm(),ze=3):i===um?(i=hm(),ze=4):ze=i===dp?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,zt=i,be===null&&(Ze=1,No(t,Xt(i,t.current)))}function $p(){var t=X.H;return X.H=Cn,t===null?Cn:t}function eg(){var t=X.A;return X.A=wT,t}function Vu(){Ze=4,Qn||(Ee&4194176)!==Ee&&Wt.current!==null||(Xa=!0),(ki&134217727)===0&&(la&134217727)===0||Be===null||Zn(Be,Ee,nn,!1)}function Hu(t,i,s){var c=Qe;Qe|=2;var f=$p(),p=eg();(Be!==t||Ee!==i)&&(Vo=null,Ja(t,i)),i=!1;var v=Ze;e:do try{if(ze!==0&&be!==null){var S=be,E=zt;switch(ze){case 8:qu(),v=6;break e;case 3:case 2:case 6:Wt.current===null&&(i=!0);var M=ze;if(ze=0,zt=null,Wa(t,S,E,M),s&&Xa){v=0;break e}break;default:M=ze,ze=0,zt=null,Wa(t,S,E,M)}}AT(),v=Ze;break}catch(q){Wp(t,q)}while(!0);return i&&t.shellSuspendCounter++,Vn=ra=null,Qe=c,X.H=f,X.A=p,be===null&&(Be=null,Ee=0,mo()),v}function AT(){for(;be!==null;)tg(be)}function MT(t,i){var s=Qe;Qe|=2;var c=$p(),f=eg();Be!==t||Ee!==i?(Vo=null,qo=Sn()+500,Ja(t,i)):Xa=Ar(t,i);e:do try{if(ze!==0&&be!==null){i=be;var p=zt;t:switch(ze){case 1:ze=0,zt=null,Wa(t,i,p,1);break;case 2:if(dm(p)){ze=0,zt=null,ng(i);break}i=function(){ze===2&&Be===t&&(ze=7),Rn(t)},p.then(i,i);break e;case 3:ze=7;break e;case 4:ze=5;break e;case 7:dm(p)?(ze=0,zt=null,ng(i)):(ze=0,zt=null,Wa(t,i,p,7));break;case 5:var v=null;switch(be.tag){case 26:v=be.memoizedState;case 5:case 27:var S=be;if(!v||Mg(v)){ze=0,zt=null;var E=S.sibling;if(E!==null)be=E;else{var M=S.return;M!==null?(be=M,Fo(M)):be=null}break t}}ze=0,zt=null,Wa(t,i,p,5);break;case 6:ze=0,zt=null,Wa(t,i,p,6);break;case 8:qu(),Ze=6;break e;default:throw Error(r(462))}}PT();break}catch(q){Wp(t,q)}while(!0);return Vn=ra=null,X.H=c,X.A=f,Qe=s,be!==null?0:(Be=null,Ee=0,mo(),Ze)}function PT(){for(;be!==null&&!eS();)tg(be)}function tg(t){var i=Cp(t.alternate,t,Xn);t.memoizedProps=t.pendingProps,i===null?Fo(t):be=i}function ng(t){var i=t,s=i.alternate;switch(i.tag){case 15:case 0:i=vp(s,i,i.pendingProps,i.type,void 0,Ee);break;case 11:i=vp(s,i,i.pendingProps,i.type.render,i.ref,Ee);break;case 5:Kl(i);default:Qp(s,i),i=be=Fp(i,Xn),i=Cp(s,i,Xn)}t.memoizedProps=t.pendingProps,i===null?Fo(t):be=i}function Wa(t,i,s,c){Vn=ra=null,Kl(i),Ba=null,Qr=0;var f=i.return;try{if(ST(t,f,i,s,Ee)){Ze=1,No(t,Xt(s,t.current)),be=null;return}}catch(p){if(f!==null)throw be=f,p;Ze=1,No(t,Xt(s,t.current)),be=null;return}i.flags&32768?(we||c===1?t=!0:Xa||(Ee&536870912)!==0?t=!1:(Qn=t=!0,(c===2||c===3||c===6)&&(c=Wt.current,c!==null&&c.tag===13&&(c.flags|=16384))),ig(i,t)):Fo(i)}function Fo(t){var i=t;do{if((i.flags&32768)!==0){ig(i,Qn);return}t=i.return;var s=RT(i.alternate,i,Xn);if(s!==null){be=s;return}if(i=i.sibling,i!==null){be=i;return}be=i=t}while(i!==null);Ze===0&&(Ze=5)}function ig(t,i){do{var s=_T(t.alternate,t);if(s!==null){s.flags&=32767,be=s;return}if(s=t.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!i&&(t=t.sibling,t!==null)){be=t;return}be=t=s}while(t!==null);Ze=6,be=null}function ag(t,i,s,c,f,p,v,S,E,M){var q=X.T,K=ae.p;try{ae.p=2,X.T=null,xT(t,i,s,c,K,f,p,v,S,E,M)}finally{X.T=q,ae.p=K}}function xT(t,i,s,c,f,p,v,S){do $a();while(ua!==null);if((Qe&6)!==0)throw Error(r(327));var E=t.finishedWork;if(c=t.finishedLanes,E===null)return null;if(t.finishedWork=null,t.finishedLanes=0,E===t.current)throw Error(r(177));t.callbackNode=null,t.callbackPriority=0,t.cancelPendingCommit=null;var M=E.lanes|E.childLanes;if(M|=Pl,dS(t,c,M,p,v,S),t===Be&&(be=Be=null,Ee=0),(E.subtreeFlags&10256)===0&&(E.flags&10256)===0||Ho||(Ho=!0,Iu=M,ju=s,IT(Ws,function(){return $a(),null})),s=(E.flags&15990)!==0,(E.subtreeFlags&15990)!==0||s?(s=X.T,X.T=null,p=ae.p,ae.p=2,v=Qe,Qe|=4,kT(t,E),jp(E,t),iT(td,t.containerInfo),ic=!!ed,td=ed=null,t.current=E,Np(t,E.alternate,E),tS(),Qe=v,ae.p=p,X.T=s):t.current=E,Ho?(Ho=!1,ua=t,fs=c):rg(t,M),M=t.pendingLanes,M===0&&(Ci=null),sS(E.stateNode),Rn(t),i!==null)for(f=t.onRecoverableError,E=0;E<i.length;E++)M=i[E],f(M.value,{componentStack:M.stack});return(fs&3)!==0&&$a(),M=t.pendingLanes,(c&4194218)!==0&&(M&42)!==0?t===Bu?hs++:(hs=0,Bu=t):hs=0,ms(0),null}function rg(t,i){(t.pooledCacheLanes&=i)===0&&(i=t.pooledCache,i!=null&&(t.pooledCache=null,Zr(i)))}function $a(){if(ua!==null){var t=ua,i=Iu;Iu=0;var s=mh(fs),c=X.T,f=ae.p;try{if(ae.p=32>s?32:s,X.T=null,ua===null)var p=!1;else{s=ju,ju=null;var v=ua,S=fs;if(ua=null,fs=0,(Qe&6)!==0)throw Error(r(331));var E=Qe;if(Qe|=4,Hp(v.current),zp(v,v.current,S,s),Qe=E,ms(0,!1),Ut&&typeof Ut.onPostCommitFiberRoot=="function")try{Ut.onPostCommitFiberRoot(Dr,v)}catch{}p=!0}return p}finally{ae.p=f,X.T=c,rg(t,i)}}return!1}function sg(t,i,s){i=Xt(s,i),i=ou(t.stateNode,i,2),t=vi(t,i,2),t!==null&&(Mr(t,2),Rn(t))}function Le(t,i,s){if(t.tag===3)sg(t,t,s);else for(;i!==null;){if(i.tag===3){sg(i,t,s);break}else if(i.tag===1){var c=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof c.componentDidCatch=="function"&&(Ci===null||!Ci.has(c))){t=Xt(s,t),s=lp(2),c=vi(i,s,2),c!==null&&(up(s,c,i,t),Mr(c,2),Rn(c));break}}i=i.return}}function Gu(t,i,s){var c=t.pingCache;if(c===null){c=t.pingCache=new OT;var f=new Set;c.set(i,f)}else f=c.get(i),f===void 0&&(f=new Set,c.set(i,f));f.has(s)||(xu=!0,f.add(s),t=NT.bind(null,t,i,s),i.then(t,t))}function NT(t,i,s){var c=t.pingCache;c!==null&&c.delete(i),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,Be===t&&(Ee&s)===s&&(Ze===4||Ze===3&&(Ee&62914560)===Ee&&300>Sn()-Lu?(Qe&2)===0&&Ja(t,0):Nu|=s,Za===Ee&&(Za=0)),Rn(t)}function og(t,i){i===0&&(i=dh()),t=li(t,i),t!==null&&(Mr(t,i),Rn(t))}function UT(t){var i=t.memoizedState,s=0;i!==null&&(s=i.retryLane),og(t,s)}function LT(t,i){var s=0;switch(t.tag){case 13:var c=t.stateNode,f=t.memoizedState;f!==null&&(s=f.retryLane);break;case 19:c=t.stateNode;break;case 22:c=t.stateNode._retryCache;break;default:throw Error(r(314))}c!==null&&c.delete(i),og(t,s)}function IT(t,i){return cl(t,i)}var Yo=null,er=null,Fu=!1,Ko=!1,Yu=!1,da=0;function Rn(t){t!==er&&t.next===null&&(er===null?Yo=er=t:er=er.next=t),Ko=!0,Fu||(Fu=!0,BT(jT))}function ms(t,i){if(!Yu&&Ko){Yu=!0;do for(var s=!1,c=Yo;c!==null;){if(t!==0){var f=c.pendingLanes;if(f===0)var p=0;else{var v=c.suspendedLanes,S=c.pingedLanes;p=(1<<31-Lt(42|t)+1)-1,p&=f&~(v&~S),p=p&201326677?p&201326677|1:p?p|2:0}p!==0&&(s=!0,ug(c,p))}else p=Ee,p=to(c,c===Be?p:0),(p&3)===0||Ar(c,p)||(s=!0,ug(c,p));c=c.next}while(s);Yu=!1}}function jT(){Ko=Fu=!1;var t=0;da!==0&&(KT()&&(t=da),da=0);for(var i=Sn(),s=null,c=Yo;c!==null;){var f=c.next,p=cg(c,i);p===0?(c.next=null,s===null?Yo=f:s.next=f,f===null&&(er=s)):(s=c,(t!==0||(p&3)!==0)&&(Ko=!0)),c=f}ms(t)}function cg(t,i){for(var s=t.suspendedLanes,c=t.pingedLanes,f=t.expirationTimes,p=t.pendingLanes&-62914561;0<p;){var v=31-Lt(p),S=1<<v,E=f[v];E===-1?((S&s)===0||(S&c)!==0)&&(f[v]=uS(S,i)):E<=i&&(t.expiredLanes|=S),p&=~S}if(i=Be,s=Ee,s=to(t,t===i?s:0),c=t.callbackNode,s===0||t===i&&ze===2||t.cancelPendingCommit!==null)return c!==null&&c!==null&&ll(c),t.callbackNode=null,t.callbackPriority=0;if((s&3)===0||Ar(t,s)){if(i=s&-s,i===t.callbackPriority)return i;switch(c!==null&&ll(c),mh(s)){case 2:case 8:s=ch;break;case 32:s=Ws;break;case 268435456:s=lh;break;default:s=Ws}return c=lg.bind(null,t),s=cl(s,c),t.callbackPriority=i,t.callbackNode=s,i}return c!==null&&c!==null&&ll(c),t.callbackPriority=2,t.callbackNode=null,2}function lg(t,i){var s=t.callbackNode;if($a()&&t.callbackNode!==s)return null;var c=Ee;return c=to(t,t===Be?c:0),c===0?null:(Zp(t,c,i),cg(t,Sn()),t.callbackNode!=null&&t.callbackNode===s?lg.bind(null,t):null)}function ug(t,i){if($a())return null;Zp(t,i,!0)}function BT(t){XT(function(){(Qe&6)!==0?cl(oh,t):t()})}function Ku(){return da===0&&(da=uh()),da}function dg(t){return t==null||typeof t=="symbol"||typeof t=="boolean"?null:typeof t=="function"?t:so(""+t)}function fg(t,i){var s=i.ownerDocument.createElement("input");return s.name=i.name,s.value=i.value,t.id&&s.setAttribute("form",t.id),i.parentNode.insertBefore(s,i),t=new FormData(t),s.parentNode.removeChild(s),t}function zT(t,i,s,c,f){if(i==="submit"&&s&&s.stateNode===f){var p=dg((f[Ot]||null).action),v=c.submitter;v&&(i=(i=v[Ot]||null)?dg(i.formAction):v.getAttribute("formAction"),i!==null&&(p=i,v=null));var S=new uo("action","action",null,c,f);t.push({event:S,listeners:[{instance:null,listener:function(){if(c.defaultPrevented){if(da!==0){var E=v?fg(f,v):new FormData(f);nu(s,{pending:!0,data:E,method:f.method,action:p},null,E)}}else typeof p=="function"&&(S.preventDefault(),E=v?fg(f,v):new FormData(f),nu(s,{pending:!0,data:E,method:f.method,action:p},p,E))},currentTarget:f}]})}}for(var Qu=0;Qu<am.length;Qu++){var Xu=am[Qu],qT=Xu.toLowerCase(),VT=Xu[0].toUpperCase()+Xu.slice(1);sn(qT,"on"+VT)}sn($h,"onAnimationEnd"),sn(em,"onAnimationIteration"),sn(tm,"onAnimationStart"),sn("dblclick","onDoubleClick"),sn("focusin","onFocus"),sn("focusout","onBlur"),sn(rT,"onTransitionRun"),sn(sT,"onTransitionStart"),sn(oT,"onTransitionCancel"),sn(nm,"onTransitionEnd"),wa("onMouseEnter",["mouseout","mouseover"]),wa("onMouseLeave",["mouseout","mouseover"]),wa("onPointerEnter",["pointerout","pointerover"]),wa("onPointerLeave",["pointerout","pointerover"]),Yi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Yi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Yi("onBeforeInput",["compositionend","keypress","textInput","paste"]),Yi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Yi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Yi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var ps="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),HT=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(ps));function hg(t,i){i=(i&4)!==0;for(var s=0;s<t.length;s++){var c=t[s],f=c.event;c=c.listeners;e:{var p=void 0;if(i)for(var v=c.length-1;0<=v;v--){var S=c[v],E=S.instance,M=S.currentTarget;if(S=S.listener,E!==p&&f.isPropagationStopped())break e;p=S,f.currentTarget=M;try{p(f)}catch(q){xo(q)}f.currentTarget=null,p=E}else for(v=0;v<c.length;v++){if(S=c[v],E=S.instance,M=S.currentTarget,S=S.listener,E!==p&&f.isPropagationStopped())break e;p=S,f.currentTarget=M;try{p(f)}catch(q){xo(q)}f.currentTarget=null,p=E}}}}function Se(t,i){var s=i[dl];s===void 0&&(s=i[dl]=new Set);var c=t+"__bubble";s.has(c)||(mg(i,t,2,!1),s.add(c))}function Zu(t,i,s){var c=0;i&&(c|=4),mg(s,t,c,i)}var Qo="_reactListening"+Math.random().toString(36).slice(2);function Ju(t){if(!t[Qo]){t[Qo]=!0,vh.forEach(function(s){s!=="selectionchange"&&(HT.has(s)||Zu(s,!1,t),Zu(s,!0,t))});var i=t.nodeType===9?t:t.ownerDocument;i===null||i[Qo]||(i[Qo]=!0,Zu("selectionchange",!1,i))}}function mg(t,i,s,c){switch(Ig(i)){case 2:var f=pk;break;case 8:f=gk;break;default:f=ud}s=f.bind(null,i,s,t),f=void 0,!bl||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(f=!0),c?f!==void 0?t.addEventListener(i,s,{capture:!0,passive:f}):t.addEventListener(i,s,!0):f!==void 0?t.addEventListener(i,s,{passive:f}):t.addEventListener(i,s,!1)}function Wu(t,i,s,c,f){var p=c;if((i&1)===0&&(i&2)===0&&c!==null)e:for(;;){if(c===null)return;var v=c.tag;if(v===3||v===4){var S=c.stateNode.containerInfo;if(S===f||S.nodeType===8&&S.parentNode===f)break;if(v===4)for(v=c.return;v!==null;){var E=v.tag;if((E===3||E===4)&&(E=v.stateNode.containerInfo,E===f||E.nodeType===8&&E.parentNode===f))return;v=v.return}for(;S!==null;){if(v=Fi(S),v===null)return;if(E=v.tag,E===5||E===6||E===26||E===27){c=p=v;continue e}S=S.parentNode}}c=c.return}Dh(function(){var M=p,q=vl(s),K=[];e:{var L=im.get(t);if(L!==void 0){var z=uo,se=t;switch(t){case"keypress":if(co(s)===0)break e;case"keydown":case"keyup":z=LS;break;case"focusin":se="focus",z=Cl;break;case"focusout":se="blur",z=Cl;break;case"beforeblur":case"afterblur":z=Cl;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":z=Ph;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":z=ES;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":z=BS;break;case $h:case em:case tm:z=wS;break;case nm:z=qS;break;case"scroll":case"scrollend":z=kS;break;case"wheel":z=HS;break;case"copy":case"cut":case"paste":z=DS;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":z=Nh;break;case"toggle":case"beforetoggle":z=FS}var me=(i&4)!==0,Je=!me&&(t==="scroll"||t==="scrollend"),x=me?L!==null?L+"Capture":null:L;me=[];for(var A=M,N;A!==null;){var G=A;if(N=G.stateNode,G=G.tag,G!==5&&G!==26&&G!==27||N===null||x===null||(G=Nr(A,x),G!=null&&me.push(gs(A,G,N))),Je)break;A=A.return}0<me.length&&(L=new z(L,se,null,s,q),K.push({event:L,listeners:me}))}}if((i&7)===0){e:{if(L=t==="mouseover"||t==="pointerover",z=t==="mouseout"||t==="pointerout",L&&s!==gl&&(se=s.relatedTarget||s.fromElement)&&(Fi(se)||se[Ea]))break e;if((z||L)&&(L=q.window===q?q:(L=q.ownerDocument)?L.defaultView||L.parentWindow:window,z?(se=s.relatedTarget||s.toElement,z=M,se=se?Fi(se):null,se!==null&&(Je=ue(se),me=se.tag,se!==Je||me!==5&&me!==27&&me!==6)&&(se=null)):(z=null,se=M),z!==se)){if(me=Ph,G="onMouseLeave",x="onMouseEnter",A="mouse",(t==="pointerout"||t==="pointerover")&&(me=Nh,G="onPointerLeave",x="onPointerEnter",A="pointer"),Je=z==null?L:xr(z),N=se==null?L:xr(se),L=new me(G,A+"leave",z,s,q),L.target=Je,L.relatedTarget=N,G=null,Fi(q)===M&&(me=new me(x,A+"enter",se,s,q),me.target=N,me.relatedTarget=Je,G=me),Je=G,z&&se)t:{for(me=z,x=se,A=0,N=me;N;N=tr(N))A++;for(N=0,G=x;G;G=tr(G))N++;for(;0<A-N;)me=tr(me),A--;for(;0<N-A;)x=tr(x),N--;for(;A--;){if(me===x||x!==null&&me===x.alternate)break t;me=tr(me),x=tr(x)}me=null}else me=null;z!==null&&pg(K,L,z,me,!1),se!==null&&Je!==null&&pg(K,Je,se,me,!0)}}e:{if(L=M?xr(M):window,z=L.nodeName&&L.nodeName.toLowerCase(),z==="select"||z==="input"&&L.type==="file")var re=Vh;else if(zh(L))if(Hh)re=tT;else{re=$S;var ye=WS}else z=L.nodeName,!z||z.toLowerCase()!=="input"||L.type!=="checkbox"&&L.type!=="radio"?M&&pl(M.elementType)&&(re=Vh):re=eT;if(re&&(re=re(t,M))){qh(K,re,s,q);break e}ye&&ye(t,L,M),t==="focusout"&&M&&L.type==="number"&&M.memoizedProps.value!=null&&ml(L,"number",L.value)}switch(ye=M?xr(M):window,t){case"focusin":(zh(ye)||ye.contentEditable==="true")&&(xa=ye,Dl=M,Vr=null);break;case"focusout":Vr=Dl=xa=null;break;case"mousedown":Al=!0;break;case"contextmenu":case"mouseup":case"dragend":Al=!1,Jh(K,s,q);break;case"selectionchange":if(aT)break;case"keydown":case"keyup":Jh(K,s,q)}var ce;if(Rl)e:{switch(t){case"compositionstart":var de="onCompositionStart";break e;case"compositionend":de="onCompositionEnd";break e;case"compositionupdate":de="onCompositionUpdate";break e}de=void 0}else Pa?jh(t,s)&&(de="onCompositionEnd"):t==="keydown"&&s.keyCode===229&&(de="onCompositionStart");de&&(Uh&&s.locale!=="ko"&&(Pa||de!=="onCompositionStart"?de==="onCompositionEnd"&&Pa&&(ce=Ah()):(ci=q,Sl="value"in ci?ci.value:ci.textContent,Pa=!0)),ye=Xo(M,de),0<ye.length&&(de=new xh(de,t,null,s,q),K.push({event:de,listeners:ye}),ce?de.data=ce:(ce=Bh(s),ce!==null&&(de.data=ce)))),(ce=KS?QS(t,s):XS(t,s))&&(de=Xo(M,"onBeforeInput"),0<de.length&&(ye=new xh("onBeforeInput","beforeinput",null,s,q),K.push({event:ye,listeners:de}),ye.data=ce)),zT(K,t,M,s,q)}hg(K,i)})}function gs(t,i,s){return{instance:t,listener:i,currentTarget:s}}function Xo(t,i){for(var s=i+"Capture",c=[];t!==null;){var f=t,p=f.stateNode;f=f.tag,f!==5&&f!==26&&f!==27||p===null||(f=Nr(t,s),f!=null&&c.unshift(gs(t,f,p)),f=Nr(t,i),f!=null&&c.push(gs(t,f,p))),t=t.return}return c}function tr(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5&&t.tag!==27);return t||null}function pg(t,i,s,c,f){for(var p=i._reactName,v=[];s!==null&&s!==c;){var S=s,E=S.alternate,M=S.stateNode;if(S=S.tag,E!==null&&E===c)break;S!==5&&S!==26&&S!==27||M===null||(E=M,f?(M=Nr(s,p),M!=null&&v.unshift(gs(s,M,E))):f||(M=Nr(s,p),M!=null&&v.push(gs(s,M,E)))),s=s.return}v.length!==0&&t.push({event:i,listeners:v})}var GT=/\r\n?/g,FT=/\u0000|\uFFFD/g;function gg(t){return(typeof t=="string"?t:""+t).replace(GT,`
`).replace(FT,"")}function vg(t,i){return i=gg(i),gg(t)===i}function Zo(){}function xe(t,i,s,c,f,p){switch(s){case"children":typeof c=="string"?i==="body"||i==="textarea"&&c===""||Da(t,c):(typeof c=="number"||typeof c=="bigint")&&i!=="body"&&Da(t,""+c);break;case"className":io(t,"class",c);break;case"tabIndex":io(t,"tabindex",c);break;case"dir":case"role":case"viewBox":case"width":case"height":io(t,s,c);break;case"style":wh(t,c,p);break;case"data":if(i!=="object"){io(t,"data",c);break}case"src":case"href":if(c===""&&(i!=="a"||s!=="href")){t.removeAttribute(s);break}if(c==null||typeof c=="function"||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=so(""+c),t.setAttribute(s,c);break;case"action":case"formAction":if(typeof c=="function"){t.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof p=="function"&&(s==="formAction"?(i!=="input"&&xe(t,i,"name",f.name,f,null),xe(t,i,"formEncType",f.formEncType,f,null),xe(t,i,"formMethod",f.formMethod,f,null),xe(t,i,"formTarget",f.formTarget,f,null)):(xe(t,i,"encType",f.encType,f,null),xe(t,i,"method",f.method,f,null),xe(t,i,"target",f.target,f,null)));if(c==null||typeof c=="symbol"||typeof c=="boolean"){t.removeAttribute(s);break}c=so(""+c),t.setAttribute(s,c);break;case"onClick":c!=null&&(t.onclick=Zo);break;case"onScroll":c!=null&&Se("scroll",t);break;case"onScrollEnd":c!=null&&Se("scrollend",t);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(s=c.__html,s!=null){if(f.children!=null)throw Error(r(60));t.innerHTML=s}}break;case"multiple":t.multiple=c&&typeof c!="function"&&typeof c!="symbol";break;case"muted":t.muted=c&&typeof c!="function"&&typeof c!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(c==null||typeof c=="function"||typeof c=="boolean"||typeof c=="symbol"){t.removeAttribute("xlink:href");break}s=so(""+c),t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,""+c):t.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":c&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,""):t.removeAttribute(s);break;case"capture":case"download":c===!0?t.setAttribute(s,""):c!==!1&&c!=null&&typeof c!="function"&&typeof c!="symbol"?t.setAttribute(s,c):t.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":c!=null&&typeof c!="function"&&typeof c!="symbol"&&!isNaN(c)&&1<=c?t.setAttribute(s,c):t.removeAttribute(s);break;case"rowSpan":case"start":c==null||typeof c=="function"||typeof c=="symbol"||isNaN(c)?t.removeAttribute(s):t.setAttribute(s,c);break;case"popover":Se("beforetoggle",t),Se("toggle",t),no(t,"popover",c);break;case"xlinkActuate":Ln(t,"http://www.w3.org/1999/xlink","xlink:actuate",c);break;case"xlinkArcrole":Ln(t,"http://www.w3.org/1999/xlink","xlink:arcrole",c);break;case"xlinkRole":Ln(t,"http://www.w3.org/1999/xlink","xlink:role",c);break;case"xlinkShow":Ln(t,"http://www.w3.org/1999/xlink","xlink:show",c);break;case"xlinkTitle":Ln(t,"http://www.w3.org/1999/xlink","xlink:title",c);break;case"xlinkType":Ln(t,"http://www.w3.org/1999/xlink","xlink:type",c);break;case"xmlBase":Ln(t,"http://www.w3.org/XML/1998/namespace","xml:base",c);break;case"xmlLang":Ln(t,"http://www.w3.org/XML/1998/namespace","xml:lang",c);break;case"xmlSpace":Ln(t,"http://www.w3.org/XML/1998/namespace","xml:space",c);break;case"is":no(t,"is",c);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=SS.get(s)||s,no(t,s,c))}}function $u(t,i,s,c,f,p){switch(s){case"style":wh(t,c,p);break;case"dangerouslySetInnerHTML":if(c!=null){if(typeof c!="object"||!("__html"in c))throw Error(r(61));if(s=c.__html,s!=null){if(f.children!=null)throw Error(r(60));t.innerHTML=s}}break;case"children":typeof c=="string"?Da(t,c):(typeof c=="number"||typeof c=="bigint")&&Da(t,""+c);break;case"onScroll":c!=null&&Se("scroll",t);break;case"onScrollEnd":c!=null&&Se("scrollend",t);break;case"onClick":c!=null&&(t.onclick=Zo);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!yh.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(f=s.endsWith("Capture"),i=s.slice(2,f?s.length-7:void 0),p=t[Ot]||null,p=p!=null?p[s]:null,typeof p=="function"&&t.removeEventListener(i,p,f),typeof c=="function")){typeof p!="function"&&p!==null&&(s in t?t[s]=null:t.hasAttribute(s)&&t.removeAttribute(s)),t.addEventListener(i,c,f);break e}s in t?t[s]=c:c===!0?t.setAttribute(s,""):no(t,s,c)}}}function St(t,i,s){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Se("error",t),Se("load",t);var c=!1,f=!1,p;for(p in s)if(s.hasOwnProperty(p)){var v=s[p];if(v!=null)switch(p){case"src":c=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,i));default:xe(t,i,p,v,s,null)}}f&&xe(t,i,"srcSet",s.srcSet,s,null),c&&xe(t,i,"src",s.src,s,null);return;case"input":Se("invalid",t);var S=p=v=f=null,E=null,M=null;for(c in s)if(s.hasOwnProperty(c)){var q=s[c];if(q!=null)switch(c){case"name":f=q;break;case"type":v=q;break;case"checked":E=q;break;case"defaultChecked":M=q;break;case"value":p=q;break;case"defaultValue":S=q;break;case"children":case"dangerouslySetInnerHTML":if(q!=null)throw Error(r(137,i));break;default:xe(t,i,c,q,s,null)}}Ch(t,p,S,E,M,v,f,!1),ao(t);return;case"select":Se("invalid",t),c=v=p=null;for(f in s)if(s.hasOwnProperty(f)&&(S=s[f],S!=null))switch(f){case"value":p=S;break;case"defaultValue":v=S;break;case"multiple":c=S;default:xe(t,i,f,S,s,null)}i=p,s=v,t.multiple=!!c,i!=null?Oa(t,!!c,i,!1):s!=null&&Oa(t,!!c,s,!0);return;case"textarea":Se("invalid",t),p=f=c=null;for(v in s)if(s.hasOwnProperty(v)&&(S=s[v],S!=null))switch(v){case"value":c=S;break;case"defaultValue":f=S;break;case"children":p=S;break;case"dangerouslySetInnerHTML":if(S!=null)throw Error(r(91));break;default:xe(t,i,v,S,s,null)}Rh(t,c,f,p),ao(t);return;case"option":for(E in s)if(s.hasOwnProperty(E)&&(c=s[E],c!=null))switch(E){case"selected":t.selected=c&&typeof c!="function"&&typeof c!="symbol";break;default:xe(t,i,E,c,s,null)}return;case"dialog":Se("cancel",t),Se("close",t);break;case"iframe":case"object":Se("load",t);break;case"video":case"audio":for(c=0;c<ps.length;c++)Se(ps[c],t);break;case"image":Se("error",t),Se("load",t);break;case"details":Se("toggle",t);break;case"embed":case"source":case"link":Se("error",t),Se("load",t);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(M in s)if(s.hasOwnProperty(M)&&(c=s[M],c!=null))switch(M){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,i));default:xe(t,i,M,c,s,null)}return;default:if(pl(i)){for(q in s)s.hasOwnProperty(q)&&(c=s[q],c!==void 0&&$u(t,i,q,c,s,void 0));return}}for(S in s)s.hasOwnProperty(S)&&(c=s[S],c!=null&&xe(t,i,S,c,s,null))}function YT(t,i,s,c){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,p=null,v=null,S=null,E=null,M=null,q=null;for(z in s){var K=s[z];if(s.hasOwnProperty(z)&&K!=null)switch(z){case"checked":break;case"value":break;case"defaultValue":E=K;default:c.hasOwnProperty(z)||xe(t,i,z,null,c,K)}}for(var L in c){var z=c[L];if(K=s[L],c.hasOwnProperty(L)&&(z!=null||K!=null))switch(L){case"type":p=z;break;case"name":f=z;break;case"checked":M=z;break;case"defaultChecked":q=z;break;case"value":v=z;break;case"defaultValue":S=z;break;case"children":case"dangerouslySetInnerHTML":if(z!=null)throw Error(r(137,i));break;default:z!==K&&xe(t,i,L,z,c,K)}}hl(t,v,S,E,M,q,p,f);return;case"select":z=v=S=L=null;for(p in s)if(E=s[p],s.hasOwnProperty(p)&&E!=null)switch(p){case"value":break;case"multiple":z=E;default:c.hasOwnProperty(p)||xe(t,i,p,null,c,E)}for(f in c)if(p=c[f],E=s[f],c.hasOwnProperty(f)&&(p!=null||E!=null))switch(f){case"value":L=p;break;case"defaultValue":S=p;break;case"multiple":v=p;default:p!==E&&xe(t,i,f,p,c,E)}i=S,s=v,c=z,L!=null?Oa(t,!!s,L,!1):!!c!=!!s&&(i!=null?Oa(t,!!s,i,!0):Oa(t,!!s,s?[]:"",!1));return;case"textarea":z=L=null;for(S in s)if(f=s[S],s.hasOwnProperty(S)&&f!=null&&!c.hasOwnProperty(S))switch(S){case"value":break;case"children":break;default:xe(t,i,S,null,c,f)}for(v in c)if(f=c[v],p=s[v],c.hasOwnProperty(v)&&(f!=null||p!=null))switch(v){case"value":L=f;break;case"defaultValue":z=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(r(91));break;default:f!==p&&xe(t,i,v,f,c,p)}Eh(t,L,z);return;case"option":for(var se in s)if(L=s[se],s.hasOwnProperty(se)&&L!=null&&!c.hasOwnProperty(se))switch(se){case"selected":t.selected=!1;break;default:xe(t,i,se,null,c,L)}for(E in c)if(L=c[E],z=s[E],c.hasOwnProperty(E)&&L!==z&&(L!=null||z!=null))switch(E){case"selected":t.selected=L&&typeof L!="function"&&typeof L!="symbol";break;default:xe(t,i,E,L,c,z)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var me in s)L=s[me],s.hasOwnProperty(me)&&L!=null&&!c.hasOwnProperty(me)&&xe(t,i,me,null,c,L);for(M in c)if(L=c[M],z=s[M],c.hasOwnProperty(M)&&L!==z&&(L!=null||z!=null))switch(M){case"children":case"dangerouslySetInnerHTML":if(L!=null)throw Error(r(137,i));break;default:xe(t,i,M,L,c,z)}return;default:if(pl(i)){for(var Je in s)L=s[Je],s.hasOwnProperty(Je)&&L!==void 0&&!c.hasOwnProperty(Je)&&$u(t,i,Je,void 0,c,L);for(q in c)L=c[q],z=s[q],!c.hasOwnProperty(q)||L===z||L===void 0&&z===void 0||$u(t,i,q,L,c,z);return}}for(var x in s)L=s[x],s.hasOwnProperty(x)&&L!=null&&!c.hasOwnProperty(x)&&xe(t,i,x,null,c,L);for(K in c)L=c[K],z=s[K],!c.hasOwnProperty(K)||L===z||L==null&&z==null||xe(t,i,K,L,c,z)}var ed=null,td=null;function Jo(t){return t.nodeType===9?t:t.ownerDocument}function yg(t){switch(t){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function bg(t,i){if(t===0)switch(i){case"svg":return 1;case"math":return 2;default:return 0}return t===1&&i==="foreignObject"?0:t}function nd(t,i){return t==="textarea"||t==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.children=="bigint"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var id=null;function KT(){var t=window.event;return t&&t.type==="popstate"?t===id?!1:(id=t,!0):(id=null,!1)}var Sg=typeof setTimeout=="function"?setTimeout:void 0,QT=typeof clearTimeout=="function"?clearTimeout:void 0,Tg=typeof Promise=="function"?Promise:void 0,XT=typeof queueMicrotask=="function"?queueMicrotask:typeof Tg<"u"?function(t){return Tg.resolve(null).then(t).catch(ZT)}:Sg;function ZT(t){setTimeout(function(){throw t})}function ad(t,i){var s=i,c=0;do{var f=s.nextSibling;if(t.removeChild(s),f&&f.nodeType===8)if(s=f.data,s==="/$"){if(c===0){t.removeChild(f),Es(i);return}c--}else s!=="$"&&s!=="$?"&&s!=="$!"||c++;s=f}while(s);Es(i)}function rd(t){var i=t.firstChild;for(i&&i.nodeType===10&&(i=i.nextSibling);i;){var s=i;switch(i=i.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":rd(s),fl(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}t.removeChild(s)}}function JT(t,i,s,c){for(;t.nodeType===1;){var f=s;if(t.nodeName.toLowerCase()!==i.toLowerCase()){if(!c&&(t.nodeName!=="INPUT"||t.type!=="hidden"))break}else if(c){if(!t[Pr])switch(i){case"meta":if(!t.hasAttribute("itemprop"))break;return t;case"link":if(p=t.getAttribute("rel"),p==="stylesheet"&&t.hasAttribute("data-precedence"))break;if(p!==f.rel||t.getAttribute("href")!==(f.href==null?null:f.href)||t.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||t.getAttribute("title")!==(f.title==null?null:f.title))break;return t;case"style":if(t.hasAttribute("data-precedence"))break;return t;case"script":if(p=t.getAttribute("src"),(p!==(f.src==null?null:f.src)||t.getAttribute("type")!==(f.type==null?null:f.type)||t.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&p&&t.hasAttribute("async")&&!t.hasAttribute("itemprop"))break;return t;default:return t}}else if(i==="input"&&t.type==="hidden"){var p=f.name==null?null:""+f.name;if(f.type==="hidden"&&t.getAttribute("name")===p)return t}else return t;if(t=ln(t.nextSibling),t===null)break}return null}function WT(t,i,s){if(i==="")return null;for(;t.nodeType!==3;)if((t.nodeType!==1||t.nodeName!=="INPUT"||t.type!=="hidden")&&!s||(t=ln(t.nextSibling),t===null))return null;return t}function ln(t){for(;t!=null;t=t.nextSibling){var i=t.nodeType;if(i===1||i===3)break;if(i===8){if(i=t.data,i==="$"||i==="$!"||i==="$?"||i==="F!"||i==="F")break;if(i==="/$")return null}}return t}function kg(t){t=t.previousSibling;for(var i=0;t;){if(t.nodeType===8){var s=t.data;if(s==="$"||s==="$!"||s==="$?"){if(i===0)return t;i--}else s==="/$"&&i++}t=t.previousSibling}return null}function Cg(t,i,s){switch(i=Jo(s),t){case"html":if(t=i.documentElement,!t)throw Error(r(452));return t;case"head":if(t=i.head,!t)throw Error(r(453));return t;case"body":if(t=i.body,!t)throw Error(r(454));return t;default:throw Error(r(451))}}var an=new Map,Eg=new Set;function Wo(t){return typeof t.getRootNode=="function"?t.getRootNode():t.ownerDocument}var Jn=ae.d;ae.d={f:$T,r:ek,D:tk,C:nk,L:ik,m:ak,X:sk,S:rk,M:ok};function $T(){var t=Jn.f(),i=Go();return t||i}function ek(t){var i=Ra(t);i!==null&&i.tag===5&&i.type==="form"?Jm(i):Jn.r(t)}var nr=typeof document>"u"?null:document;function Rg(t,i,s){var c=nr;if(c&&typeof i=="string"&&i){var f=Kt(i);f='link[rel="'+t+'"][href="'+f+'"]',typeof s=="string"&&(f+='[crossorigin="'+s+'"]'),Eg.has(f)||(Eg.add(f),t={rel:t,crossOrigin:s,href:i},c.querySelector(f)===null&&(i=c.createElement("link"),St(i,"link",t),ft(i),c.head.appendChild(i)))}}function tk(t){Jn.D(t),Rg("dns-prefetch",t,null)}function nk(t,i){Jn.C(t,i),Rg("preconnect",t,i)}function ik(t,i,s){Jn.L(t,i,s);var c=nr;if(c&&t&&i){var f='link[rel="preload"][as="'+Kt(i)+'"]';i==="image"&&s&&s.imageSrcSet?(f+='[imagesrcset="'+Kt(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(f+='[imagesizes="'+Kt(s.imageSizes)+'"]')):f+='[href="'+Kt(t)+'"]';var p=f;switch(i){case"style":p=ir(t);break;case"script":p=ar(t)}an.has(p)||(t=J({rel:"preload",href:i==="image"&&s&&s.imageSrcSet?void 0:t,as:i},s),an.set(p,t),c.querySelector(f)!==null||i==="style"&&c.querySelector(vs(p))||i==="script"&&c.querySelector(ys(p))||(i=c.createElement("link"),St(i,"link",t),ft(i),c.head.appendChild(i)))}}function ak(t,i){Jn.m(t,i);var s=nr;if(s&&t){var c=i&&typeof i.as=="string"?i.as:"script",f='link[rel="modulepreload"][as="'+Kt(c)+'"][href="'+Kt(t)+'"]',p=f;switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":p=ar(t)}if(!an.has(p)&&(t=J({rel:"modulepreload",href:t},i),an.set(p,t),s.querySelector(f)===null)){switch(c){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(ys(p)))return}c=s.createElement("link"),St(c,"link",t),ft(c),s.head.appendChild(c)}}}function rk(t,i,s){Jn.S(t,i,s);var c=nr;if(c&&t){var f=_a(c).hoistableStyles,p=ir(t);i=i||"default";var v=f.get(p);if(!v){var S={loading:0,preload:null};if(v=c.querySelector(vs(p)))S.loading=5;else{t=J({rel:"stylesheet",href:t,"data-precedence":i},s),(s=an.get(p))&&sd(t,s);var E=v=c.createElement("link");ft(E),St(E,"link",t),E._p=new Promise(function(M,q){E.onload=M,E.onerror=q}),E.addEventListener("load",function(){S.loading|=1}),E.addEventListener("error",function(){S.loading|=2}),S.loading|=4,$o(v,i,c)}v={type:"stylesheet",instance:v,count:1,state:S},f.set(p,v)}}}function sk(t,i){Jn.X(t,i);var s=nr;if(s&&t){var c=_a(s).hoistableScripts,f=ar(t),p=c.get(f);p||(p=s.querySelector(ys(f)),p||(t=J({src:t,async:!0},i),(i=an.get(f))&&od(t,i),p=s.createElement("script"),ft(p),St(p,"link",t),s.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},c.set(f,p))}}function ok(t,i){Jn.M(t,i);var s=nr;if(s&&t){var c=_a(s).hoistableScripts,f=ar(t),p=c.get(f);p||(p=s.querySelector(ys(f)),p||(t=J({src:t,async:!0,type:"module"},i),(i=an.get(f))&&od(t,i),p=s.createElement("script"),ft(p),St(p,"link",t),s.head.appendChild(p)),p={type:"script",instance:p,count:1,state:null},c.set(f,p))}}function _g(t,i,s,c){var f=(f=ri.current)?Wo(f):null;if(!f)throw Error(r(446));switch(t){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(i=ir(s.href),s=_a(f).hoistableStyles,c=s.get(i),c||(c={type:"style",instance:null,count:0,state:null},s.set(i,c)),c):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){t=ir(s.href);var p=_a(f).hoistableStyles,v=p.get(t);if(v||(f=f.ownerDocument||f,v={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},p.set(t,v),(p=f.querySelector(vs(t)))&&!p._p&&(v.instance=p,v.state.loading=5),an.has(t)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},an.set(t,s),p||ck(f,t,s,v.state))),i&&c===null)throw Error(r(528,""));return v}if(i&&c!==null)throw Error(r(529,""));return null;case"script":return i=s.async,s=s.src,typeof s=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=ar(s),s=_a(f).hoistableScripts,c=s.get(i),c||(c={type:"script",instance:null,count:0,state:null},s.set(i,c)),c):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,t))}}function ir(t){return'href="'+Kt(t)+'"'}function vs(t){return'link[rel="stylesheet"]['+t+"]"}function wg(t){return J({},t,{"data-precedence":t.precedence,precedence:null})}function ck(t,i,s,c){t.querySelector('link[rel="preload"][as="style"]['+i+"]")?c.loading=1:(i=t.createElement("link"),c.preload=i,i.addEventListener("load",function(){return c.loading|=1}),i.addEventListener("error",function(){return c.loading|=2}),St(i,"link",s),ft(i),t.head.appendChild(i))}function ar(t){return'[src="'+Kt(t)+'"]'}function ys(t){return"script[async]"+t}function Og(t,i,s){if(i.count++,i.instance===null)switch(i.type){case"style":var c=t.querySelector('style[data-href~="'+Kt(s.href)+'"]');if(c)return i.instance=c,ft(c),c;var f=J({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return c=(t.ownerDocument||t).createElement("style"),ft(c),St(c,"style",f),$o(c,s.precedence,t),i.instance=c;case"stylesheet":f=ir(s.href);var p=t.querySelector(vs(f));if(p)return i.state.loading|=4,i.instance=p,ft(p),p;c=wg(s),(f=an.get(f))&&sd(c,f),p=(t.ownerDocument||t).createElement("link"),ft(p);var v=p;return v._p=new Promise(function(S,E){v.onload=S,v.onerror=E}),St(p,"link",c),i.state.loading|=4,$o(p,s.precedence,t),i.instance=p;case"script":return p=ar(s.src),(f=t.querySelector(ys(p)))?(i.instance=f,ft(f),f):(c=s,(f=an.get(p))&&(c=J({},s),od(c,f)),t=t.ownerDocument||t,f=t.createElement("script"),ft(f),St(f,"link",c),t.head.appendChild(f),i.instance=f);case"void":return null;default:throw Error(r(443,i.type))}else i.type==="stylesheet"&&(i.state.loading&4)===0&&(c=i.instance,i.state.loading|=4,$o(c,s.precedence,t));return i.instance}function $o(t,i,s){for(var c=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=c.length?c[c.length-1]:null,p=f,v=0;v<c.length;v++){var S=c[v];if(S.dataset.precedence===i)p=S;else if(p!==f)break}p?p.parentNode.insertBefore(t,p.nextSibling):(i=s.nodeType===9?s.head:s,i.insertBefore(t,i.firstChild))}function sd(t,i){t.crossOrigin==null&&(t.crossOrigin=i.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=i.referrerPolicy),t.title==null&&(t.title=i.title)}function od(t,i){t.crossOrigin==null&&(t.crossOrigin=i.crossOrigin),t.referrerPolicy==null&&(t.referrerPolicy=i.referrerPolicy),t.integrity==null&&(t.integrity=i.integrity)}var ec=null;function Dg(t,i,s){if(ec===null){var c=new Map,f=ec=new Map;f.set(s,c)}else f=ec,c=f.get(s),c||(c=new Map,f.set(s,c));if(c.has(t))return c;for(c.set(t,null),s=s.getElementsByTagName(t),f=0;f<s.length;f++){var p=s[f];if(!(p[Pr]||p[kt]||t==="link"&&p.getAttribute("rel")==="stylesheet")&&p.namespaceURI!=="http://www.w3.org/2000/svg"){var v=p.getAttribute(i)||"";v=t+v;var S=c.get(v);S?S.push(p):c.set(v,[p])}}return c}function Ag(t,i,s){t=t.ownerDocument||t,t.head.insertBefore(s,i==="title"?t.querySelector("head > title"):null)}function lk(t,i,s){if(s===1||i.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof i.precedence!="string"||typeof i.href!="string"||i.href==="")break;return!0;case"link":if(typeof i.rel!="string"||typeof i.href!="string"||i.href===""||i.onLoad||i.onError)break;switch(i.rel){case"stylesheet":return t=i.disabled,typeof i.precedence=="string"&&t==null;default:return!0}case"script":if(i.async&&typeof i.async!="function"&&typeof i.async!="symbol"&&!i.onLoad&&!i.onError&&i.src&&typeof i.src=="string")return!0}return!1}function Mg(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}var bs=null;function uk(){}function dk(t,i,s){if(bs===null)throw Error(r(475));var c=bs;if(i.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var f=ir(s.href),p=t.querySelector(vs(f));if(p){t=p._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(c.count++,c=tc.bind(c),t.then(c,c)),i.state.loading|=4,i.instance=p,ft(p);return}p=t.ownerDocument||t,s=wg(s),(f=an.get(f))&&sd(s,f),p=p.createElement("link"),ft(p);var v=p;v._p=new Promise(function(S,E){v.onload=S,v.onerror=E}),St(p,"link",s),i.instance=p}c.stylesheets===null&&(c.stylesheets=new Map),c.stylesheets.set(i,t),(t=i.state.preload)&&(i.state.loading&3)===0&&(c.count++,i=tc.bind(c),t.addEventListener("load",i),t.addEventListener("error",i))}}function fk(){if(bs===null)throw Error(r(475));var t=bs;return t.stylesheets&&t.count===0&&cd(t,t.stylesheets),0<t.count?function(i){var s=setTimeout(function(){if(t.stylesheets&&cd(t,t.stylesheets),t.unsuspend){var c=t.unsuspend;t.unsuspend=null,c()}},6e4);return t.unsuspend=i,function(){t.unsuspend=null,clearTimeout(s)}}:null}function tc(){if(this.count--,this.count===0){if(this.stylesheets)cd(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var nc=null;function cd(t,i){t.stylesheets=null,t.unsuspend!==null&&(t.count++,nc=new Map,i.forEach(hk,t),nc=null,tc.call(t))}function hk(t,i){if(!(i.state.loading&4)){var s=nc.get(t);if(s)var c=s.get(null);else{s=new Map,nc.set(t,s);for(var f=t.querySelectorAll("link[data-precedence],style[data-precedence]"),p=0;p<f.length;p++){var v=f[p];(v.nodeName==="LINK"||v.getAttribute("media")!=="not all")&&(s.set(v.dataset.precedence,v),c=v)}c&&s.set(null,c)}f=i.instance,v=f.getAttribute("data-precedence"),p=s.get(v)||c,p===c&&s.set(null,f),s.set(v,f),this.count++,c=tc.bind(this),f.addEventListener("load",c),f.addEventListener("error",c),p?p.parentNode.insertBefore(f,p.nextSibling):(t=t.nodeType===9?t.head:t,t.insertBefore(f,t.firstChild)),i.state.loading|=4}}var Ss={$$typeof:T,Provider:null,Consumer:null,_currentValue:Ce,_currentValue2:Ce,_threadCount:0};function mk(t,i,s,c,f,p,v,S){this.tag=1,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ul(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.finishedLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ul(0),this.hiddenUpdates=ul(null),this.identifierPrefix=c,this.onUncaughtError=f,this.onCaughtError=p,this.onRecoverableError=v,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=S,this.incompleteTransitions=new Map}function Pg(t,i,s,c,f,p,v,S,E,M,q,K){return t=new mk(t,i,s,v,S,E,M,K),i=1,p===!0&&(i|=24),p=tn(3,null,null,i),t.current=p,p.stateNode=t,i=zl(),i.refCount++,t.pooledCache=i,i.refCount++,p.memoizedState={element:c,isDehydrated:s,cache:i},Su(p),t}function xg(t){return t?(t=La,t):La}function Ng(t,i,s,c,f,p){f=xg(f),c.context===null?c.context=f:c.pendingContext=f,c=gi(i),c.payload={element:s},p=p===void 0?null:p,p!==null&&(c.callback=p),s=vi(t,c,i),s!==null&&(wt(s,t,i),is(s,t,i))}function Ug(t,i){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var s=t.retryLane;t.retryLane=s!==0&&s<i?s:i}}function ld(t,i){Ug(t,i),(t=t.alternate)&&Ug(t,i)}function Lg(t){if(t.tag===13){var i=li(t,67108864);i!==null&&wt(i,t,67108864),ld(t,67108864)}}var ic=!0;function pk(t,i,s,c){var f=X.T;X.T=null;var p=ae.p;try{ae.p=2,ud(t,i,s,c)}finally{ae.p=p,X.T=f}}function gk(t,i,s,c){var f=X.T;X.T=null;var p=ae.p;try{ae.p=8,ud(t,i,s,c)}finally{ae.p=p,X.T=f}}function ud(t,i,s,c){if(ic){var f=dd(c);if(f===null)Wu(t,i,c,ac,s),jg(t,c);else if(yk(f,t,i,s,c))c.stopPropagation();else if(jg(t,c),i&4&&-1<vk.indexOf(t)){for(;f!==null;){var p=Ra(f);if(p!==null)switch(p.tag){case 3:if(p=p.stateNode,p.current.memoizedState.isDehydrated){var v=Gi(p.pendingLanes);if(v!==0){var S=p;for(S.pendingLanes|=2,S.entangledLanes|=2;v;){var E=1<<31-Lt(v);S.entanglements[1]|=E,v&=~E}Rn(p),(Qe&6)===0&&(qo=Sn()+500,ms(0))}}break;case 13:S=li(p,2),S!==null&&wt(S,p,2),Go(),ld(p,2)}if(p=dd(c),p===null&&Wu(t,i,c,ac,s),p===f)break;f=p}f!==null&&c.stopPropagation()}else Wu(t,i,c,null,s)}}function dd(t){return t=vl(t),fd(t)}var ac=null;function fd(t){if(ac=null,t=Fi(t),t!==null){var i=ue(t);if(i===null)t=null;else{var s=i.tag;if(s===13){if(t=je(i),t!==null)return t;t=null}else if(s===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;t=null}else i!==t&&(t=null)}}return ac=t,null}function Ig(t){switch(t){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(nS()){case oh:return 2;case ch:return 8;case Ws:case iS:return 32;case lh:return 268435456;default:return 32}default:return 32}}var hd=!1,Ei=null,Ri=null,_i=null,Ts=new Map,ks=new Map,wi=[],vk="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function jg(t,i){switch(t){case"focusin":case"focusout":Ei=null;break;case"dragenter":case"dragleave":Ri=null;break;case"mouseover":case"mouseout":_i=null;break;case"pointerover":case"pointerout":Ts.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":ks.delete(i.pointerId)}}function Cs(t,i,s,c,f,p){return t===null||t.nativeEvent!==p?(t={blockedOn:i,domEventName:s,eventSystemFlags:c,nativeEvent:p,targetContainers:[f]},i!==null&&(i=Ra(i),i!==null&&Lg(i)),t):(t.eventSystemFlags|=c,i=t.targetContainers,f!==null&&i.indexOf(f)===-1&&i.push(f),t)}function yk(t,i,s,c,f){switch(i){case"focusin":return Ei=Cs(Ei,t,i,s,c,f),!0;case"dragenter":return Ri=Cs(Ri,t,i,s,c,f),!0;case"mouseover":return _i=Cs(_i,t,i,s,c,f),!0;case"pointerover":var p=f.pointerId;return Ts.set(p,Cs(Ts.get(p)||null,t,i,s,c,f)),!0;case"gotpointercapture":return p=f.pointerId,ks.set(p,Cs(ks.get(p)||null,t,i,s,c,f)),!0}return!1}function Bg(t){var i=Fi(t.target);if(i!==null){var s=ue(i);if(s!==null){if(i=s.tag,i===13){if(i=je(s),i!==null){t.blockedOn=i,fS(t.priority,function(){if(s.tag===13){var c=qt(),f=li(s,c);f!==null&&wt(f,s,c),ld(s,c)}});return}}else if(i===3&&s.stateNode.current.memoizedState.isDehydrated){t.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}t.blockedOn=null}function rc(t){if(t.blockedOn!==null)return!1;for(var i=t.targetContainers;0<i.length;){var s=dd(t.nativeEvent);if(s===null){s=t.nativeEvent;var c=new s.constructor(s.type,s);gl=c,s.target.dispatchEvent(c),gl=null}else return i=Ra(s),i!==null&&Lg(i),t.blockedOn=s,!1;i.shift()}return!0}function zg(t,i,s){rc(t)&&s.delete(i)}function bk(){hd=!1,Ei!==null&&rc(Ei)&&(Ei=null),Ri!==null&&rc(Ri)&&(Ri=null),_i!==null&&rc(_i)&&(_i=null),Ts.forEach(zg),ks.forEach(zg)}function sc(t,i){t.blockedOn===i&&(t.blockedOn=null,hd||(hd=!0,a.unstable_scheduleCallback(a.unstable_NormalPriority,bk)))}var oc=null;function qg(t){oc!==t&&(oc=t,a.unstable_scheduleCallback(a.unstable_NormalPriority,function(){oc===t&&(oc=null);for(var i=0;i<t.length;i+=3){var s=t[i],c=t[i+1],f=t[i+2];if(typeof c!="function"){if(fd(c||s)===null)continue;break}var p=Ra(s);p!==null&&(t.splice(i,3),i-=3,nu(p,{pending:!0,data:f,method:s.method,action:c},c,f))}}))}function Es(t){function i(E){return sc(E,t)}Ei!==null&&sc(Ei,t),Ri!==null&&sc(Ri,t),_i!==null&&sc(_i,t),Ts.forEach(i),ks.forEach(i);for(var s=0;s<wi.length;s++){var c=wi[s];c.blockedOn===t&&(c.blockedOn=null)}for(;0<wi.length&&(s=wi[0],s.blockedOn===null);)Bg(s),s.blockedOn===null&&wi.shift();if(s=(t.ownerDocument||t).$$reactFormReplay,s!=null)for(c=0;c<s.length;c+=3){var f=s[c],p=s[c+1],v=f[Ot]||null;if(typeof p=="function")v||qg(s);else if(v){var S=null;if(p&&p.hasAttribute("formAction")){if(f=p,v=p[Ot]||null)S=v.formAction;else if(fd(f)!==null)continue}else S=v.action;typeof S=="function"?s[c+1]=S:(s.splice(c,3),c-=3),qg(s)}}}function md(t){this._internalRoot=t}cc.prototype.render=md.prototype.render=function(t){var i=this._internalRoot;if(i===null)throw Error(r(409));var s=i.current,c=qt();Ng(s,c,t,i,null,null)},cc.prototype.unmount=md.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var i=t.containerInfo;t.tag===0&&$a(),Ng(t.current,2,null,t,null,null),Go(),i[Ea]=null}};function cc(t){this._internalRoot=t}cc.prototype.unstable_scheduleHydration=function(t){if(t){var i=ph();t={blockedOn:null,target:t,priority:i};for(var s=0;s<wi.length&&i!==0&&i<wi[s].priority;s++);wi.splice(s,0,t),s===0&&Bg(t)}};var Vg=e.version;if(Vg!=="19.0.0")throw Error(r(527,Vg,"19.0.0"));ae.findDOMNode=function(t){var i=t._reactInternals;if(i===void 0)throw typeof t.render=="function"?Error(r(188)):(t=Object.keys(t).join(","),Error(r(268,t)));return t=Z(i),t=t!==null?fe(t):null,t=t===null?null:t.stateNode,t};var Sk={bundleType:0,version:"19.0.0",rendererPackageName:"react-dom",currentDispatcherRef:X,findFiberByHostInstance:Fi,reconcilerVersion:"19.0.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var lc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lc.isDisabled&&lc.supportsFiber)try{Dr=lc.inject(Sk),Ut=lc}catch{}}return _s.createRoot=function(t,i){if(!o(t))throw Error(r(299));var s=!1,c="",f=rp,p=sp,v=op,S=null;return i!=null&&(i.unstable_strictMode===!0&&(s=!0),i.identifierPrefix!==void 0&&(c=i.identifierPrefix),i.onUncaughtError!==void 0&&(f=i.onUncaughtError),i.onCaughtError!==void 0&&(p=i.onCaughtError),i.onRecoverableError!==void 0&&(v=i.onRecoverableError),i.unstable_transitionCallbacks!==void 0&&(S=i.unstable_transitionCallbacks)),i=Pg(t,1,!1,null,null,s,c,f,p,v,S,null),t[Ea]=i.current,Ju(t.nodeType===8?t.parentNode:t),new md(i)},_s.hydrateRoot=function(t,i,s){if(!o(t))throw Error(r(299));var c=!1,f="",p=rp,v=sp,S=op,E=null,M=null;return s!=null&&(s.unstable_strictMode===!0&&(c=!0),s.identifierPrefix!==void 0&&(f=s.identifierPrefix),s.onUncaughtError!==void 0&&(p=s.onUncaughtError),s.onCaughtError!==void 0&&(v=s.onCaughtError),s.onRecoverableError!==void 0&&(S=s.onRecoverableError),s.unstable_transitionCallbacks!==void 0&&(E=s.unstable_transitionCallbacks),s.formState!==void 0&&(M=s.formState)),i=Pg(t,1,!0,i,s??null,c,f,p,v,S,E,M),i.context=xg(null),s=i.current,c=qt(),f=gi(c),f.callback=null,vi(s,f,c),i.current.lanes=c,Mr(i,c),Rn(i),t[Ea]=i.current,Ju(t),new cc(i)},_s.version="19.0.0",_s}var Wg;function Ak(){if(Wg)return vd.exports;Wg=1;function a(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(a)}catch(e){console.error(e)}}return a(),vd.exports=Dk(),vd.exports}var Mk=Ak(),$g={};function Pk(a,e){return e.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(r){if(r!=="default"&&!(r in a)){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(a,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}})}),Object.freeze(a)}var xk=Object.defineProperty,Nk=(a,e,n)=>e in a?xk(a,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[e]=n,ev=(a,e,n)=>Nk(a,typeof e!="symbol"?e+"":e,n);let Ht=class{constructor(){ev(this,"_locking"),ev(this,"_locks"),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e;const n=new Promise(o=>e=()=>{this._locks-=1,o()}),r=this._locking.then(()=>e);return this._locking=this._locking.then(()=>n),r}};function $e(a,e){if(!a)throw new Error(e)}const Uk=34028234663852886e22,Lk=-34028234663852886e22,Ik=4294967295,jk=2147483647,Bk=-2147483648;function pc(a){if(typeof a!="number")throw new Error("invalid int 32: "+typeof a);if(!Number.isInteger(a)||a>jk||a<Bk)throw new Error("invalid int 32: "+a)}function Vd(a){if(typeof a!="number")throw new Error("invalid uint 32: "+typeof a);if(!Number.isInteger(a)||a>Ik||a<0)throw new Error("invalid uint 32: "+a)}function y0(a){if(typeof a!="number")throw new Error("invalid float 32: "+typeof a);if(Number.isFinite(a)&&(a>Uk||a<Lk))throw new Error("invalid float 32: "+a)}const b0=Symbol("@bufbuild/protobuf/enum-type");function zk(a){const e=a[b0];return $e(e,"missing enum type on enum object"),e}function S0(a,e,n,r){a[b0]=T0(e,n.map(o=>({no:o.no,name:o.name,localName:a[o.no]})))}function T0(a,e,n){const r=Object.create(null),o=Object.create(null),l=[];for(const u of e){const d=k0(u);l.push(d),r[u.name]=d,o[u.no]=d}return{typeName:a,values:l,findName(u){return r[u]},findNumber(u){return o[u]}}}function qk(a,e,n){const r={};for(const o of e){const l=k0(o);r[l.localName]=l.no,r[l.no]=l.localName}return S0(r,a,e),r}function k0(a){return"localName"in a?a:Object.assign(Object.assign({},a),{localName:a.name})}class Pf{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){const r=this.getType(),o=r.runtime.bin,l=o.makeReadOptions(n);return o.readMessage(this,l.readerFactory(e),e.byteLength,l),this}fromJson(e,n){const r=this.getType(),o=r.runtime.json,l=o.makeReadOptions(n);return o.readMessage(r,e,l,this),this}fromJsonString(e,n){let r;try{r=JSON.parse(e)}catch(o){throw new Error("cannot decode ".concat(this.getType().typeName," from JSON: ").concat(o instanceof Error?o.message:String(o)))}return this.fromJson(r,n)}toBinary(e){const n=this.getType(),r=n.runtime.bin,o=r.makeWriteOptions(e),l=o.writerFactory();return r.writeMessage(this,l,o),l.finish()}toJson(e){const n=this.getType(),r=n.runtime.json,o=r.makeWriteOptions(e);return r.writeMessage(this,o)}toJsonString(e){var n;const r=this.toJson(e);return JSON.stringify(r,null,(n=e==null?void 0:e.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function Vk(a,e,n,r){var o;const l=(o=r==null?void 0:r.localName)!==null&&o!==void 0?o:e.substring(e.lastIndexOf(".")+1),u={[l]:function(d){a.util.initFields(this),a.util.initPartial(d,this)}}[l];return Object.setPrototypeOf(u.prototype,new Pf),Object.assign(u,{runtime:a,typeName:e,fields:a.util.newFieldList(n),fromBinary(d,h){return new u().fromBinary(d,h)},fromJson(d,h){return new u().fromJson(d,h)},fromJsonString(d,h){return new u().fromJsonString(d,h)},equals(d,h){return a.util.equals(u,d,h)}}),u}function Hk(){let a=0,e=0;for(let r=0;r<28;r+=7){let o=this.buf[this.pos++];if(a|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[a,e]}let n=this.buf[this.pos++];if(a|=(n&15)<<28,e=(n&112)>>4,(n&128)==0)return this.assertBounds(),[a,e];for(let r=3;r<=31;r+=7){let o=this.buf[this.pos++];if(e|=(o&127)<<r,(o&128)==0)return this.assertBounds(),[a,e]}throw new Error("invalid varint")}function Td(a,e,n){for(let l=0;l<28;l=l+7){const u=a>>>l,d=!(!(u>>>7)&&e==0),h=(d?u|128:u)&255;if(n.push(h),!d)return}const r=a>>>28&15|(e&7)<<4,o=e>>3!=0;if(n.push((o?r|128:r)&255),!!o){for(let l=3;l<31;l=l+7){const u=e>>>l,d=!!(u>>>7),h=(d?u|128:u)&255;if(n.push(h),!d)return}n.push(e>>>31&1)}}const gc=4294967296;function tv(a){const e=a[0]==="-";e&&(a=a.slice(1));const n=1e6;let r=0,o=0;function l(u,d){const h=Number(a.slice(u,d));o*=n,r=r*n+h,r>=gc&&(o=o+(r/gc|0),r=r%gc)}return l(-24,-18),l(-18,-12),l(-12,-6),l(-6),e?E0(r,o):xf(r,o)}function Gk(a,e){let n=xf(a,e);const r=n.hi&2147483648;r&&(n=E0(n.lo,n.hi));const o=C0(n.lo,n.hi);return r?"-"+o:o}function C0(a,e){if({lo:a,hi:e}=Fk(a,e),e<=2097151)return String(gc*e+a);const n=a&16777215,r=(a>>>24|e<<8)&16777215,o=e>>16&65535;let l=n+r*6777216+o*6710656,u=r+o*8147497,d=o*2;const h=1e7;return l>=h&&(u+=Math.floor(l/h),l%=h),u>=h&&(d+=Math.floor(u/h),u%=h),d.toString()+nv(u)+nv(l)}function Fk(a,e){return{lo:a>>>0,hi:e>>>0}}function xf(a,e){return{lo:a|0,hi:e|0}}function E0(a,e){return e=~e,a?a=~a+1:e+=1,xf(a,e)}const nv=a=>{const e=String(a);return"0000000".slice(e.length)+e};function iv(a,e){if(a>=0){for(;a>127;)e.push(a&127|128),a=a>>>7;e.push(a)}else{for(let n=0;n<9;n++)e.push(a&127|128),a=a>>7;e.push(1)}}function Yk(){let a=this.buf[this.pos++],e=a&127;if((a&128)==0)return this.assertBounds(),e;if(a=this.buf[this.pos++],e|=(a&127)<<7,(a&128)==0)return this.assertBounds(),e;if(a=this.buf[this.pos++],e|=(a&127)<<14,(a&128)==0)return this.assertBounds(),e;if(a=this.buf[this.pos++],e|=(a&127)<<21,(a&128)==0)return this.assertBounds(),e;a=this.buf[this.pos++],e|=(a&15)<<28;for(let n=5;(a&128)!==0&&n<10;n++)a=this.buf[this.pos++];if((a&128)!=0)throw new Error("invalid varint");return this.assertBounds(),e>>>0}function Kk(){const a=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof a.getBigInt64=="function"&&typeof a.getBigUint64=="function"&&typeof a.setBigInt64=="function"&&typeof a.setBigUint64=="function"&&(typeof process!="object"||typeof $g!="object"||$g.BUF_BIGINT_DISABLE!=="1")){const o=BigInt("-9223372036854775808"),l=BigInt("9223372036854775807"),u=BigInt("0"),d=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(h){const m=typeof h=="bigint"?h:BigInt(h);if(m>l||m<o)throw new Error("int64 invalid: ".concat(h));return m},uParse(h){const m=typeof h=="bigint"?h:BigInt(h);if(m>d||m<u)throw new Error("uint64 invalid: ".concat(h));return m},enc(h){return a.setBigInt64(0,this.parse(h),!0),{lo:a.getInt32(0,!0),hi:a.getInt32(4,!0)}},uEnc(h){return a.setBigInt64(0,this.uParse(h),!0),{lo:a.getInt32(0,!0),hi:a.getInt32(4,!0)}},dec(h,m){return a.setInt32(0,h,!0),a.setInt32(4,m,!0),a.getBigInt64(0,!0)},uDec(h,m){return a.setInt32(0,h,!0),a.setInt32(4,m,!0),a.getBigUint64(0,!0)}}}const n=o=>$e(/^-?[0-9]+$/.test(o),"int64 invalid: ".concat(o)),r=o=>$e(/^[0-9]+$/.test(o),"uint64 invalid: ".concat(o));return{zero:"0",supported:!1,parse(o){return typeof o!="string"&&(o=o.toString()),n(o),o},uParse(o){return typeof o!="string"&&(o=o.toString()),r(o),o},enc(o){return typeof o!="string"&&(o=o.toString()),n(o),tv(o)},uEnc(o){return typeof o!="string"&&(o=o.toString()),r(o),tv(o)},dec(o,l){return Gk(o,l)},uDec(o,l){return C0(o,l)}}}const Ge=Kk();var Y;(function(a){a[a.DOUBLE=1]="DOUBLE",a[a.FLOAT=2]="FLOAT",a[a.INT64=3]="INT64",a[a.UINT64=4]="UINT64",a[a.INT32=5]="INT32",a[a.FIXED64=6]="FIXED64",a[a.FIXED32=7]="FIXED32",a[a.BOOL=8]="BOOL",a[a.STRING=9]="STRING",a[a.BYTES=12]="BYTES",a[a.UINT32=13]="UINT32",a[a.SFIXED32=15]="SFIXED32",a[a.SFIXED64=16]="SFIXED64",a[a.SINT32=17]="SINT32",a[a.SINT64=18]="SINT64"})(Y||(Y={}));var ji;(function(a){a[a.BIGINT=0]="BIGINT",a[a.STRING=1]="STRING"})(ji||(ji={}));function Di(a,e,n){if(e===n)return!0;if(a==Y.BYTES){if(!(e instanceof Uint8Array)||!(n instanceof Uint8Array)||e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==n[r])return!1;return!0}switch(a){case Y.UINT64:case Y.FIXED64:case Y.INT64:case Y.SFIXED64:case Y.SINT64:return e==n}return!1}function yr(a,e){switch(a){case Y.BOOL:return!1;case Y.UINT64:case Y.FIXED64:case Y.INT64:case Y.SFIXED64:case Y.SINT64:return e==0?Ge.zero:"0";case Y.DOUBLE:case Y.FLOAT:return 0;case Y.BYTES:return new Uint8Array(0);case Y.STRING:return"";default:return 0}}function R0(a,e){switch(a){case Y.BOOL:return e===!1;case Y.STRING:return e==="";case Y.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}var nt;(function(a){a[a.Varint=0]="Varint",a[a.Bit64=1]="Bit64",a[a.LengthDelimited=2]="LengthDelimited",a[a.StartGroup=3]="StartGroup",a[a.EndGroup=4]="EndGroup",a[a.Bit32=5]="Bit32"})(nt||(nt={}));class Qk{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let o=0;o<this.chunks.length;o++)e+=this.chunks[o].length;let n=new Uint8Array(e),r=0;for(let o=0;o<this.chunks.length;o++)n.set(this.chunks[o],r),r+=this.chunks[o].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Vd(e);e>127;)this.buf.push(e&127|128),e=e>>>7;return this.buf.push(e),this}int32(e){return pc(e),iv(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){y0(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){Vd(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){pc(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return pc(e),e=(e<<1^e>>31)>>>0,iv(e,this.buf),this}sfixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=Ge.enc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),r=new DataView(n.buffer),o=Ge.uEnc(e);return r.setInt32(0,o.lo,!0),r.setInt32(4,o.hi,!0),this.raw(n)}int64(e){let n=Ge.enc(e);return Td(n.lo,n.hi,this.buf),this}sint64(e){let n=Ge.enc(e),r=n.hi>>31,o=n.lo<<1^r,l=(n.hi<<1|n.lo>>>31)^r;return Td(o,l,this.buf),this}uint64(e){let n=Ge.uEnc(e);return Td(n.lo,n.hi,this.buf),this}}class Xk{constructor(e,n){this.varint64=Hk,this.uint32=Yk,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,r=e&7;if(n<=0||r<0||r>5)throw new Error("illegal tag: field no "+n+" wire type "+r);return[n,r]}skip(e,n){let r=this.pos;switch(e){case nt.Varint:for(;this.buf[this.pos++]&128;);break;case nt.Bit64:this.pos+=4;case nt.Bit32:this.pos+=4;break;case nt.LengthDelimited:let o=this.uint32();this.pos+=o;break;case nt.StartGroup:for(;;){const[l,u]=this.tag();if(u===nt.EndGroup){if(n!==void 0&&l!==n)throw new Error("invalid end group tag");break}this.skip(u,l)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return Ge.dec(...this.varint64())}uint64(){return Ge.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),r=-(e&1);return e=(e>>>1|(n&1)<<31)^r,n=n>>>1^r,Ge.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Ge.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Ge.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}}function Zk(a,e,n,r){let o;return{typeName:e,extendee:n,get field(){if(!o){const l=typeof r=="function"?r():r;l.name=e.split(".").pop(),l.jsonName="[".concat(e,"]"),o=a.util.newFieldList([l]).list()[0]}return o},runtime:a}}function _0(a){const e=a.field.localName,n=Object.create(null);return n[e]=Jk(a),[n,()=>n[e]]}function Jk(a){const e=a.field;if(e.repeated)return[];if(e.default!==void 0)return e.default;switch(e.kind){case"enum":return e.T.values[0].no;case"scalar":return yr(e.T,e.L);case"message":const n=e.T,r=new n;return n.fieldWrapper?n.fieldWrapper.unwrapField(r):r;case"map":throw"map fields are not allowed to be extensions"}}function Wk(a,e){if(!e.repeated&&(e.kind=="enum"||e.kind=="scalar")){for(let n=a.length-1;n>=0;--n)if(a[n].no==e.no)return[a[n]];return[]}return a.filter(n=>n.no===e.no)}let Wn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Gc=[];for(let a=0;a<Wn.length;a++)Gc[Wn[a].charCodeAt(0)]=a;Gc[45]=Wn.indexOf("+");Gc[95]=Wn.indexOf("/");const w0={dec(a){let e=a.length*3/4;a[a.length-2]=="="?e-=2:a[a.length-1]=="="&&(e-=1);let n=new Uint8Array(e),r=0,o=0,l,u=0;for(let d=0;d<a.length;d++){if(l=Gc[a.charCodeAt(d)],l===void 0)switch(a[d]){case"=":o=0;case`
`:case"\r":case"	":case" ":continue;default:throw Error("invalid base64 string.")}switch(o){case 0:u=l,o=1;break;case 1:n[r++]=u<<2|(l&48)>>4,u=l,o=2;break;case 2:n[r++]=(u&15)<<4|(l&60)>>2,u=l,o=3;break;case 3:n[r++]=(u&3)<<6|l,o=0;break}}if(o==1)throw Error("invalid base64 string.");return n.subarray(0,r)},enc(a){let e="",n=0,r,o=0;for(let l=0;l<a.length;l++)switch(r=a[l],n){case 0:e+=Wn[r>>2],o=(r&3)<<4,n=1;break;case 1:e+=Wn[o|r>>4],o=(r&15)<<2,n=2;break;case 2:e+=Wn[o|r>>6],e+=Wn[r&63],n=0;break}return n&&(e+=Wn[o],e+="=",n==1&&(e+="=")),e}};function $k(a,e,n){D0(e,a);const r=e.runtime.bin.makeReadOptions(n),o=Wk(a.getType().runtime.bin.listUnknownFields(a),e.field),[l,u]=_0(e);for(const d of o)e.runtime.bin.readField(l,r.readerFactory(d.data),e.field,d.wireType,r);return u()}function eC(a,e,n,r){D0(e,a);const o=e.runtime.bin.makeReadOptions(r),l=e.runtime.bin.makeWriteOptions(r);if(O0(a,e)){const m=a.getType().runtime.bin.listUnknownFields(a).filter(g=>g.no!=e.field.no);a.getType().runtime.bin.discardUnknownFields(a);for(const g of m)a.getType().runtime.bin.onUnknownField(a,g.no,g.wireType,g.data)}const u=l.writerFactory();let d=e.field;!d.opt&&!d.repeated&&(d.kind=="enum"||d.kind=="scalar")&&(d=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(d,n,u,l);const h=o.readerFactory(u.finish());for(;h.pos<h.len;){const[m,g]=h.tag(),y=h.skip(g,m);a.getType().runtime.bin.onUnknownField(a,m,g,y)}}function O0(a,e){const n=a.getType();return e.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(a).find(r=>r.no==e.field.no)}function D0(a,e){$e(a.extendee.typeName==e.getType().typeName,"extension ".concat(a.typeName," can only be applied to message ").concat(a.extendee.typeName))}function A0(a,e){const n=a.localName;if(a.repeated)return e[n].length>0;if(a.oneof)return e[a.oneof.localName].case===n;switch(a.kind){case"enum":case"scalar":return a.opt||a.req?e[n]!==void 0:a.kind=="enum"?e[n]!==a.T.values[0].no:!R0(a.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function av(a,e){const n=a.localName,r=!a.opt&&!a.req;if(a.repeated)e[n]=[];else if(a.oneof)e[a.oneof.localName]={case:void 0};else switch(a.kind){case"map":e[n]={};break;case"enum":e[n]=r?a.T.values[0].no:void 0;break;case"scalar":e[n]=r?yr(a.T,a.L):void 0;break;case"message":e[n]=void 0;break}}function ma(a,e){if(a===null||typeof a!="object"||!Object.getOwnPropertyNames(Pf.prototype).every(r=>r in a&&typeof a[r]=="function"))return!1;const n=a.getType();return n===null||typeof n!="function"||!("typeName"in n)||typeof n.typeName!="string"?!1:e===void 0?!0:n.typeName==e.typeName}function M0(a,e){return ma(e)||!a.fieldWrapper?e:a.fieldWrapper.wrapField(e)}Y.DOUBLE,Y.FLOAT,Y.INT64,Y.UINT64,Y.INT32,Y.UINT32,Y.BOOL,Y.STRING,Y.BYTES;const rv={ignoreUnknownFields:!1},sv={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function tC(a){return a?Object.assign(Object.assign({},rv),a):rv}function nC(a){return a?Object.assign(Object.assign({},sv),a):sv}const Mc=Symbol(),vc=Symbol();function iC(){return{makeReadOptions:tC,makeWriteOptions:nC,readMessage(a,e,n,r){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error("cannot decode message ".concat(a.typeName," from JSON: ").concat(wn(e)));r=r??new a;const o=new Map,l=n.typeRegistry;for(const[u,d]of Object.entries(e)){const h=a.fields.findJsonName(u);if(h){if(h.oneof){if(d===null&&h.kind=="scalar")continue;const m=o.get(h.oneof);if(m!==void 0)throw new Error("cannot decode message ".concat(a.typeName,' from JSON: multiple keys for oneof "').concat(h.oneof.name,'" present: "').concat(m,'", "').concat(u,'"'));o.set(h.oneof,u)}ov(r,d,h,n,a)}else{let m=!1;if(l!=null&&l.findExtension&&u.startsWith("[")&&u.endsWith("]")){const g=l.findExtension(u.substring(1,u.length-1));if(g&&g.extendee.typeName==a.typeName){m=!0;const[y,b]=_0(g);ov(y,d,g.field,n,g),eC(r,g,b(),n)}}if(!m&&!n.ignoreUnknownFields)throw new Error("cannot decode message ".concat(a.typeName,' from JSON: key "').concat(u,'" is unknown'))}}return r},writeMessage(a,e){const n=a.getType(),r={};let o;try{for(o of n.fields.byNumber()){if(!A0(o,a)){if(o.req)throw"required field not set";if(!e.emitDefaultValues||!rC(o))continue}const u=o.oneof?a[o.oneof.localName].value:a[o.localName],d=cv(o,u,e);d!==void 0&&(r[e.useProtoFieldName?o.name:o.jsonName]=d)}const l=e.typeRegistry;if(l!=null&&l.findExtensionFor)for(const u of n.runtime.bin.listUnknownFields(a)){const d=l.findExtensionFor(n.typeName,u.no);if(d&&O0(a,d)){const h=$k(a,d,e),m=cv(d.field,h,e);m!==void 0&&(r[d.field.jsonName]=m)}}}catch(l){const u=o?"cannot encode field ".concat(n.typeName,".").concat(o.name," to JSON"):"cannot encode message ".concat(n.typeName," to JSON"),d=l instanceof Error?l.message:String(l);throw new Error(u+(d.length>0?": ".concat(d):""))}return r},readScalar(a,e,n){return Us(a,e,n??ji.BIGINT,!0)},writeScalar(a,e,n){if(e!==void 0&&(n||R0(a,e)))return yc(a,e)},debug:wn}}function wn(a){if(a===null)return"null";switch(typeof a){case"object":return Array.isArray(a)?"array":"object";case"string":return a.length>100?"string":'"'.concat(a.split('"').join('\\"'),'"');default:return String(a)}}function ov(a,e,n,r,o){let l=n.localName;if(n.repeated){if($e(n.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error("cannot decode field ".concat(o.typeName,".").concat(n.name," from JSON: ").concat(wn(e)));const u=a[l];for(const d of e){if(d===null)throw new Error("cannot decode field ".concat(o.typeName,".").concat(n.name," from JSON: ").concat(wn(d)));switch(n.kind){case"message":u.push(n.T.fromJson(d,r));break;case"enum":const h=kd(n.T,d,r.ignoreUnknownFields,!0);h!==vc&&u.push(h);break;case"scalar":try{u.push(Us(n.T,d,n.L,!0))}catch(m){let g="cannot decode field ".concat(o.typeName,".").concat(n.name," from JSON: ").concat(wn(d));throw m instanceof Error&&m.message.length>0&&(g+=": ".concat(m.message)),new Error(g)}break}}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error("cannot decode field ".concat(o.typeName,".").concat(n.name," from JSON: ").concat(wn(e)));const u=a[l];for(const[d,h]of Object.entries(e)){if(h===null)throw new Error("cannot decode field ".concat(o.typeName,".").concat(n.name," from JSON: map value null"));let m;try{m=aC(n.K,d)}catch(g){let y="cannot decode map key for field ".concat(o.typeName,".").concat(n.name," from JSON: ").concat(wn(e));throw g instanceof Error&&g.message.length>0&&(y+=": ".concat(g.message)),new Error(y)}switch(n.V.kind){case"message":u[m]=n.V.T.fromJson(h,r);break;case"enum":const g=kd(n.V.T,h,r.ignoreUnknownFields,!0);g!==vc&&(u[m]=g);break;case"scalar":try{u[m]=Us(n.V.T,h,ji.BIGINT,!0)}catch(y){let b="cannot decode map value for field ".concat(o.typeName,".").concat(n.name," from JSON: ").concat(wn(e));throw y instanceof Error&&y.message.length>0&&(b+=": ".concat(y.message)),new Error(b)}break}}}else switch(n.oneof&&(a=a[n.oneof.localName]={case:l},l="value"),n.kind){case"message":const u=n.T;if(e===null&&u.typeName!="google.protobuf.Value")return;let d=a[l];ma(d)?d.fromJson(e,r):(a[l]=d=u.fromJson(e,r),u.fieldWrapper&&!n.oneof&&(a[l]=u.fieldWrapper.unwrapField(d)));break;case"enum":const h=kd(n.T,e,r.ignoreUnknownFields,!1);switch(h){case Mc:av(n,a);break;case vc:break;default:a[l]=h;break}break;case"scalar":try{const m=Us(n.T,e,n.L,!1);switch(m){case Mc:av(n,a);break;default:a[l]=m;break}}catch(m){let g="cannot decode field ".concat(o.typeName,".").concat(n.name," from JSON: ").concat(wn(e));throw m instanceof Error&&m.message.length>0&&(g+=": ".concat(m.message)),new Error(g)}break}}function aC(a,e){if(a===Y.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1;break}return Us(a,e,ji.BIGINT,!0).toString()}function Us(a,e,n,r){if(e===null)return r?yr(a,n):Mc;switch(a){case Y.DOUBLE:case Y.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const o=Number(e);if(Number.isNaN(o)||!Number.isFinite(o))break;return a==Y.FLOAT&&y0(o),o;case Y.INT32:case Y.FIXED32:case Y.SFIXED32:case Y.SINT32:case Y.UINT32:let l;if(typeof e=="number"?l=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(l=Number(e)),l===void 0)break;return a==Y.UINT32||a==Y.FIXED32?Vd(l):pc(l),l;case Y.INT64:case Y.SFIXED64:case Y.SINT64:if(typeof e!="number"&&typeof e!="string")break;const u=Ge.parse(e);return n?u.toString():u;case Y.FIXED64:case Y.UINT64:if(typeof e!="number"&&typeof e!="string")break;const d=Ge.uParse(e);return n?d.toString():d;case Y.BOOL:if(typeof e!="boolean")break;return e;case Y.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case Y.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return w0.dec(e)}throw new Error}function kd(a,e,n,r){if(e===null)return a.typeName=="google.protobuf.NullValue"?0:r?a.values[0].no:Mc;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const o=a.findName(e);if(o!==void 0)return o.no;if(n)return vc;break}throw new Error("cannot decode enum ".concat(a.typeName," from JSON: ").concat(wn(e)))}function rC(a){return a.repeated||a.kind=="map"?!0:!(a.oneof||a.kind=="message"||a.opt||a.req)}function cv(a,e,n){if(a.kind=="map"){$e(typeof e=="object"&&e!=null);const r={},o=Object.entries(e);switch(a.V.kind){case"scalar":for(const[u,d]of o)r[u.toString()]=yc(a.V.T,d);break;case"message":for(const[u,d]of o)r[u.toString()]=d.toJson(n);break;case"enum":const l=a.V.T;for(const[u,d]of o)r[u.toString()]=Cd(l,d,n.enumAsInteger);break}return n.emitDefaultValues||o.length>0?r:void 0}if(a.repeated){$e(Array.isArray(e));const r=[];switch(a.kind){case"scalar":for(let o=0;o<e.length;o++)r.push(yc(a.T,e[o]));break;case"enum":for(let o=0;o<e.length;o++)r.push(Cd(a.T,e[o],n.enumAsInteger));break;case"message":for(let o=0;o<e.length;o++)r.push(e[o].toJson(n));break}return n.emitDefaultValues||r.length>0?r:void 0}switch(a.kind){case"scalar":return yc(a.T,e);case"enum":return Cd(a.T,e,n.enumAsInteger);case"message":return M0(a.T,e).toJson(n)}}function Cd(a,e,n){var r;if($e(typeof e=="number"),a.typeName=="google.protobuf.NullValue")return null;if(n)return e;const o=a.findNumber(e);return(r=o==null?void 0:o.name)!==null&&r!==void 0?r:e}function yc(a,e){switch(a){case Y.INT32:case Y.SFIXED32:case Y.SINT32:case Y.FIXED32:case Y.UINT32:return $e(typeof e=="number"),e;case Y.FLOAT:case Y.DOUBLE:return $e(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case Y.STRING:return $e(typeof e=="string"),e;case Y.BOOL:return $e(typeof e=="boolean"),e;case Y.UINT64:case Y.FIXED64:case Y.INT64:case Y.SFIXED64:case Y.SINT64:return $e(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case Y.BYTES:return $e(e instanceof Uint8Array),w0.enc(e)}}const rr=Symbol("@bufbuild/protobuf/unknown-fields"),lv={readUnknownFields:!0,readerFactory:a=>new Xk(a)},uv={writeUnknownFields:!0,writerFactory:()=>new Qk};function sC(a){return a?Object.assign(Object.assign({},lv),a):lv}function oC(a){return a?Object.assign(Object.assign({},uv),a):uv}function cC(){return{makeReadOptions:sC,makeWriteOptions:oC,listUnknownFields(a){var e;return(e=a[rr])!==null&&e!==void 0?e:[]},discardUnknownFields(a){delete a[rr]},writeUnknownFields(a,e){const r=a[rr];if(r)for(const o of r)e.tag(o.no,o.wireType).raw(o.data)},onUnknownField(a,e,n,r){const o=a;Array.isArray(o[rr])||(o[rr]=[]),o[rr].push({no:e,wireType:n,data:r})},readMessage(a,e,n,r,o){const l=a.getType(),u=o?e.len:e.pos+n;let d,h;for(;e.pos<u&&([d,h]=e.tag(),!(o===!0&&h==nt.EndGroup));){const m=l.fields.find(d);if(!m){const g=e.skip(h,d);r.readUnknownFields&&this.onUnknownField(a,d,h,g);continue}dv(a,e,m,h,r)}if(o&&(h!=nt.EndGroup||d!==n))throw new Error("invalid end group tag")},readField:dv,writeMessage(a,e,n){const r=a.getType();for(const o of r.fields.byNumber()){if(!A0(o,a)){if(o.req)throw new Error("cannot encode field ".concat(r.typeName,".").concat(o.name," to binary: required field not set"));continue}const l=o.oneof?a[o.oneof.localName].value:a[o.localName];fv(o,l,e,n)}return n.writeUnknownFields&&this.writeUnknownFields(a,e),e},writeField(a,e,n,r){e!==void 0&&fv(a,e,n,r)}}}function dv(a,e,n,r,o){let{repeated:l,localName:u}=n;switch(n.oneof&&(a=a[n.oneof.localName],a.case!=u&&delete a.value,a.case=u,u="value"),n.kind){case"scalar":case"enum":const d=n.kind=="enum"?Y.INT32:n.T;let h=Pc;if(n.kind=="scalar"&&n.L>0&&(h=uC),l){let b=a[u];if(r==nt.LengthDelimited&&d!=Y.STRING&&d!=Y.BYTES){let C=e.uint32()+e.pos;for(;e.pos<C;)b.push(h(e,d))}else b.push(h(e,d))}else a[u]=h(e,d);break;case"message":const m=n.T;l?a[u].push(bc(e,new m,o,n)):ma(a[u])?bc(e,a[u],o,n):(a[u]=bc(e,new m,o,n),m.fieldWrapper&&!n.oneof&&!n.repeated&&(a[u]=m.fieldWrapper.unwrapField(a[u])));break;case"map":let[g,y]=lC(n,e,o);a[u][g]=y;break}}function bc(a,e,n,r){const o=e.getType().runtime.bin,l=r==null?void 0:r.delimited;return o.readMessage(e,a,l?r.no:a.uint32(),n,l),e}function lC(a,e,n){const r=e.uint32(),o=e.pos+r;let l,u;for(;e.pos<o;){const[d]=e.tag();switch(d){case 1:l=Pc(e,a.K);break;case 2:switch(a.V.kind){case"scalar":u=Pc(e,a.V.T);break;case"enum":u=e.int32();break;case"message":u=bc(e,new a.V.T,n,void 0);break}break}}if(l===void 0&&(l=yr(a.K,ji.BIGINT)),typeof l!="string"&&typeof l!="number"&&(l=l.toString()),u===void 0)switch(a.V.kind){case"scalar":u=yr(a.V.T,ji.BIGINT);break;case"enum":u=a.V.T.values[0].no;break;case"message":u=new a.V.T;break}return[l,u]}function uC(a,e){const n=Pc(a,e);return typeof n=="bigint"?n.toString():n}function Pc(a,e){switch(e){case Y.STRING:return a.string();case Y.BOOL:return a.bool();case Y.DOUBLE:return a.double();case Y.FLOAT:return a.float();case Y.INT32:return a.int32();case Y.INT64:return a.int64();case Y.UINT64:return a.uint64();case Y.FIXED64:return a.fixed64();case Y.BYTES:return a.bytes();case Y.FIXED32:return a.fixed32();case Y.SFIXED32:return a.sfixed32();case Y.SFIXED64:return a.sfixed64();case Y.SINT64:return a.sint64();case Y.UINT32:return a.uint32();case Y.SINT32:return a.sint32()}}function fv(a,e,n,r){$e(e!==void 0);const o=a.repeated;switch(a.kind){case"scalar":case"enum":let l=a.kind=="enum"?Y.INT32:a.T;if(o)if($e(Array.isArray(e)),a.packed)fC(n,l,a.no,e);else for(const u of e)Ls(n,l,a.no,u);else Ls(n,l,a.no,e);break;case"message":if(o){$e(Array.isArray(e));for(const u of e)hv(n,r,a,u)}else hv(n,r,a,e);break;case"map":$e(typeof e=="object"&&e!=null);for(const[u,d]of Object.entries(e))dC(n,r,a,u,d);break}}function dC(a,e,n,r,o){a.tag(n.no,nt.LengthDelimited),a.fork();let l=r;switch(n.K){case Y.INT32:case Y.FIXED32:case Y.UINT32:case Y.SFIXED32:case Y.SINT32:l=Number.parseInt(r);break;case Y.BOOL:$e(r=="true"||r=="false"),l=r=="true";break}switch(Ls(a,n.K,1,l),n.V.kind){case"scalar":Ls(a,n.V.T,2,o);break;case"enum":Ls(a,Y.INT32,2,o);break;case"message":$e(o!==void 0),a.tag(2,nt.LengthDelimited).bytes(o.toBinary(e));break}a.join()}function hv(a,e,n,r){const o=M0(n.T,r);n.delimited?a.tag(n.no,nt.StartGroup).raw(o.toBinary(e)).tag(n.no,nt.EndGroup):a.tag(n.no,nt.LengthDelimited).bytes(o.toBinary(e))}function Ls(a,e,n,r){$e(r!==void 0);let[o,l]=P0(e);a.tag(n,o)[l](r)}function fC(a,e,n,r){if(!r.length)return;a.tag(n,nt.LengthDelimited).fork();let[,o]=P0(e);for(let l=0;l<r.length;l++)a[o](r[l]);a.join()}function P0(a){let e=nt.Varint;switch(a){case Y.BYTES:case Y.STRING:e=nt.LengthDelimited;break;case Y.DOUBLE:case Y.FIXED64:case Y.SFIXED64:e=nt.Bit64;break;case Y.FIXED32:case Y.SFIXED32:case Y.FLOAT:e=nt.Bit32;break}const n=Y[a].toLowerCase();return[e,n]}function hC(){return{setEnumType:S0,initPartial(a,e){if(a===void 0)return;const n=e.getType();for(const r of n.fields.byMember()){const o=r.localName,l=e,u=a;if(u[o]!=null)switch(r.kind){case"oneof":const d=u[o].case;if(d===void 0)continue;const h=r.findField(d);let m=u[o].value;h&&h.kind=="message"&&!ma(m,h.T)?m=new h.T(m):h&&h.kind==="scalar"&&h.T===Y.BYTES&&(m=ws(m)),l[o]={case:d,value:m};break;case"scalar":case"enum":let g=u[o];r.T===Y.BYTES&&(g=r.repeated?g.map(ws):ws(g)),l[o]=g;break;case"map":switch(r.V.kind){case"scalar":case"enum":if(r.V.T===Y.BYTES)for(const[T,C]of Object.entries(u[o]))l[o][T]=ws(C);else Object.assign(l[o],u[o]);break;case"message":const b=r.V.T;for(const T of Object.keys(u[o])){let C=u[o][T];b.fieldWrapper||(C=new b(C)),l[o][T]=C}break}break;case"message":const y=r.T;if(r.repeated)l[o]=u[o].map(b=>ma(b,y)?b:new y(b));else{const b=u[o];y.fieldWrapper?y.typeName==="google.protobuf.BytesValue"?l[o]=ws(b):l[o]=b:l[o]=ma(b,y)?b:new y(b)}break}}},equals(a,e,n){return e===n?!0:!e||!n?!1:a.fields.byMember().every(r=>{const o=e[r.localName],l=n[r.localName];if(r.repeated){if(o.length!==l.length)return!1;switch(r.kind){case"message":return o.every((u,d)=>r.T.equals(u,l[d]));case"scalar":return o.every((u,d)=>Di(r.T,u,l[d]));case"enum":return o.every((u,d)=>Di(Y.INT32,u,l[d]))}throw new Error("repeated cannot contain ".concat(r.kind))}switch(r.kind){case"message":return r.T.equals(o,l);case"enum":return Di(Y.INT32,o,l);case"scalar":return Di(r.T,o,l);case"oneof":if(o.case!==l.case)return!1;const u=r.findField(o.case);if(u===void 0)return!0;switch(u.kind){case"message":return u.T.equals(o.value,l.value);case"enum":return Di(Y.INT32,o.value,l.value);case"scalar":return Di(u.T,o.value,l.value)}throw new Error("oneof cannot contain ".concat(u.kind));case"map":const d=Object.keys(o).concat(Object.keys(l));switch(r.V.kind){case"message":const h=r.V.T;return d.every(g=>h.equals(o[g],l[g]));case"enum":return d.every(g=>Di(Y.INT32,o[g],l[g]));case"scalar":const m=r.V.T;return d.every(g=>Di(m,o[g],l[g]))}break}})},clone(a){const e=a.getType(),n=new e,r=n;for(const o of e.fields.byMember()){const l=a[o.localName];let u;if(o.repeated)u=l.map(uc);else if(o.kind=="map"){u=r[o.localName];for(const[d,h]of Object.entries(l))u[d]=uc(h)}else o.kind=="oneof"?u=o.findField(l.case)?{case:l.case,value:uc(l.value)}:{case:void 0}:u=uc(l);r[o.localName]=u}for(const o of e.runtime.bin.listUnknownFields(a))e.runtime.bin.onUnknownField(r,o.no,o.wireType,o.data);return n}}}function uc(a){if(a===void 0)return a;if(ma(a))return a.clone();if(a instanceof Uint8Array){const e=new Uint8Array(a.byteLength);return e.set(a),e}return a}function ws(a){return a instanceof Uint8Array?a:new Uint8Array(a)}function mC(a,e,n){return{syntax:a,json:iC(),bin:cC(),util:Object.assign(Object.assign({},hC()),{newFieldList:e,initFields:n}),makeMessageType(r,o,l){return Vk(this,r,o,l)},makeEnum:qk,makeEnumType:T0,getEnumType:zk,makeExtension(r,o,l){return Zk(this,r,o,l)}}}class pC{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){const n={};for(const r of this.list())n[r.jsonName]=n[r.name]=r;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){const n={};for(const r of this.list())n[r.no]=r;this.numbers=n}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort((e,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let n;for(const r of this.list())r.oneof?r.oneof!==n&&(n=r.oneof,e.push(n)):e.push(r)}return this.members}}function x0(a,e){const n=N0(a);return e?n:TC(SC(n))}function gC(a){return x0(a,!1)}const vC=N0;function N0(a){let e=!1;const n=[];for(let r=0;r<a.length;r++){let o=a.charAt(r);switch(o){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(o),e=!1;break;default:e&&(e=!1,o=o.toUpperCase()),n.push(o);break}}return n.join("")}const yC=new Set(["constructor","toString","toJSON","valueOf"]),bC=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),U0=a=>"".concat(a,"$"),SC=a=>bC.has(a)?U0(a):a,TC=a=>yC.has(a)?U0(a):a;class kC{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=gC(e)}addField(e){$e(e.oneof===this,"field ".concat(e.name," not one of ").concat(this.name)),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let n=0;n<this.fields.length;n++)this._lookup[this.fields[n].localName]=this.fields[n]}return this._lookup[e]}}function CC(a,e){var n,r,o,l,u,d;const h=[];let m;for(const g of typeof a=="function"?a():a){const y=g;if(y.localName=x0(g.name,g.oneof!==void 0),y.jsonName=(n=g.jsonName)!==null&&n!==void 0?n:vC(g.name),y.repeated=(r=g.repeated)!==null&&r!==void 0?r:!1,g.kind=="scalar"&&(y.L=(o=g.L)!==null&&o!==void 0?o:ji.BIGINT),y.delimited=(l=g.delimited)!==null&&l!==void 0?l:!1,y.req=(u=g.req)!==null&&u!==void 0?u:!1,y.opt=(d=g.opt)!==null&&d!==void 0?d:!1,g.packed===void 0&&(y.packed=g.kind=="enum"||g.kind=="scalar"&&g.T!=Y.BYTES&&g.T!=Y.STRING),g.oneof!==void 0){const b=typeof g.oneof=="string"?g.oneof:g.oneof.name;(!m||m.name!=b)&&(m=new kC(b)),y.oneof=m,m.addField(y)}h.push(y)}return h}const I=mC("proto3",a=>new pC(a,e=>CC(e)),a=>{for(const e of a.getType().fields.byMember()){if(e.opt)continue;const n=e.localName,r=a;if(e.repeated){r[n]=[];continue}switch(e.kind){case"oneof":r[n]={case:void 0};break;case"enum":r[n]=0;break;case"map":r[n]={};break;case"scalar":r[n]=yr(e.T,e.L);break}}});class Pt extends Pf{constructor(e){super(),this.seconds=Ge.zero,this.nanos=0,I.util.initPartial(e,this)}fromJson(e,n){if(typeof e!="string")throw new Error("cannot decode google.protobuf.Timestamp from JSON: ".concat(I.json.debug(e)));const r=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!r)throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");const o=Date.parse(r[1]+"-"+r[2]+"-"+r[3]+"T"+r[4]+":"+r[5]+":"+r[6]+(r[8]?r[8]:"Z"));if(Number.isNaN(o))throw new Error("cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string");if(o<Date.parse("0001-01-01T00:00:00Z")||o>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");return this.seconds=Ge.parse(o/1e3),this.nanos=0,r[7]&&(this.nanos=parseInt("1"+r[7]+"0".repeat(9-r[7].length))-1e9),this}toJson(e){const n=Number(this.seconds)*1e3;if(n<Date.parse("0001-01-01T00:00:00Z")||n>Date.parse("9999-12-31T23:59:59Z"))throw new Error("cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive");if(this.nanos<0)throw new Error("cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative");let r="Z";if(this.nanos>0){const o=(this.nanos+1e9).toString().substring(1);o.substring(3)==="000000"?r="."+o.substring(0,3)+"Z":o.substring(6)==="000"?r="."+o.substring(0,6)+"Z":r="."+o+"Z"}return new Date(n).toISOString().replace(".000Z",r)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return Pt.fromDate(new Date)}static fromDate(e){const n=e.getTime();return new Pt({seconds:Ge.parse(Math.floor(n/1e3)),nanos:n%1e3*1e6})}static fromBinary(e,n){return new Pt().fromBinary(e,n)}static fromJson(e,n){return new Pt().fromJson(e,n)}static fromJsonString(e,n){return new Pt().fromJsonString(e,n)}static equals(e,n){return I.util.equals(Pt,e,n)}}Pt.runtime=I;Pt.typeName="google.protobuf.Timestamp";Pt.fields=I.util.newFieldList(()=>[{no:1,name:"seconds",kind:"scalar",T:3},{no:2,name:"nanos",kind:"scalar",T:5}]);const EC=I.makeMessageType("livekit.MetricsBatch",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Pt},{no:3,name:"str_data",kind:"scalar",T:9,repeated:!0},{no:4,name:"time_series",kind:"message",T:RC,repeated:!0},{no:5,name:"events",kind:"message",T:wC,repeated:!0}]),RC=I.makeMessageType("livekit.TimeSeriesMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"samples",kind:"message",T:_C,repeated:!0},{no:5,name:"rid",kind:"scalar",T:13}]),_C=I.makeMessageType("livekit.MetricSample",()=>[{no:1,name:"timestamp_ms",kind:"scalar",T:3},{no:2,name:"normalized_timestamp",kind:"message",T:Pt},{no:3,name:"value",kind:"scalar",T:2}]),wC=I.makeMessageType("livekit.EventMetric",()=>[{no:1,name:"label",kind:"scalar",T:13},{no:2,name:"participant_identity",kind:"scalar",T:13},{no:3,name:"track_sid",kind:"scalar",T:13},{no:4,name:"start_timestamp_ms",kind:"scalar",T:3},{no:5,name:"end_timestamp_ms",kind:"scalar",T:3,opt:!0},{no:6,name:"normalized_start_timestamp",kind:"message",T:Pt},{no:7,name:"normalized_end_timestamp",kind:"message",T:Pt,opt:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"rid",kind:"scalar",T:13}]),L0=I.makeEnum("livekit.BackupCodecPolicy",[{no:0,name:"REGRESSION"},{no:1,name:"SIMULCAST"}]),hn=I.makeEnum("livekit.TrackType",[{no:0,name:"AUDIO"},{no:1,name:"VIDEO"},{no:2,name:"DATA"}]),ot=I.makeEnum("livekit.TrackSource",[{no:0,name:"UNKNOWN"},{no:1,name:"CAMERA"},{no:2,name:"MICROPHONE"},{no:3,name:"SCREEN_SHARE"},{no:4,name:"SCREEN_SHARE_AUDIO"}]),Nf=I.makeEnum("livekit.VideoQuality",[{no:0,name:"LOW"},{no:1,name:"MEDIUM"},{no:2,name:"HIGH"},{no:3,name:"OFF"}]),xs=I.makeEnum("livekit.ConnectionQuality",[{no:0,name:"POOR"},{no:1,name:"GOOD"},{no:2,name:"EXCELLENT"},{no:3,name:"LOST"}]),Bs=I.makeEnum("livekit.ClientConfigSetting",[{no:0,name:"UNSET"},{no:1,name:"DISABLED"},{no:2,name:"ENABLED"}]),pn=I.makeEnum("livekit.DisconnectReason",[{no:0,name:"UNKNOWN_REASON"},{no:1,name:"CLIENT_INITIATED"},{no:2,name:"DUPLICATE_IDENTITY"},{no:3,name:"SERVER_SHUTDOWN"},{no:4,name:"PARTICIPANT_REMOVED"},{no:5,name:"ROOM_DELETED"},{no:6,name:"STATE_MISMATCH"},{no:7,name:"JOIN_FAILURE"},{no:8,name:"MIGRATION"},{no:9,name:"SIGNAL_CLOSE"},{no:10,name:"ROOM_CLOSED"},{no:11,name:"USER_UNAVAILABLE"},{no:12,name:"USER_REJECTED"},{no:13,name:"SIP_TRUNK_FAILURE"}]),sr=I.makeEnum("livekit.ReconnectReason",[{no:0,name:"RR_UNKNOWN"},{no:1,name:"RR_SIGNAL_DISCONNECTED"},{no:2,name:"RR_PUBLISHER_FAILED"},{no:3,name:"RR_SUBSCRIBER_FAILED"},{no:4,name:"RR_SWITCH_CANDIDATE"}]),OC=I.makeEnum("livekit.SubscriptionError",[{no:0,name:"SE_UNKNOWN"},{no:1,name:"SE_CODEC_UNSUPPORTED"},{no:2,name:"SE_TRACK_NOTFOUND"}]),On=I.makeEnum("livekit.AudioTrackFeature",[{no:0,name:"TF_STEREO"},{no:1,name:"TF_NO_DTX"},{no:2,name:"TF_AUTO_GAIN_CONTROL"},{no:3,name:"TF_ECHO_CANCELLATION"},{no:4,name:"TF_NOISE_SUPPRESSION"},{no:5,name:"TF_ENHANCED_NOISE_CANCELLATION"}]),Uf=I.makeMessageType("livekit.Room",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"empty_timeout",kind:"scalar",T:13},{no:14,name:"departure_timeout",kind:"scalar",T:13},{no:4,name:"max_participants",kind:"scalar",T:13},{no:5,name:"creation_time",kind:"scalar",T:3},{no:15,name:"creation_time_ms",kind:"scalar",T:3},{no:6,name:"turn_password",kind:"scalar",T:9},{no:7,name:"enabled_codecs",kind:"message",T:xc,repeated:!0},{no:8,name:"metadata",kind:"scalar",T:9},{no:9,name:"num_participants",kind:"scalar",T:13},{no:11,name:"num_publishers",kind:"scalar",T:13},{no:10,name:"active_recording",kind:"scalar",T:8},{no:13,name:"version",kind:"message",T:Q0}]),xc=I.makeMessageType("livekit.Codec",()=>[{no:1,name:"mime",kind:"scalar",T:9},{no:2,name:"fmtp_line",kind:"scalar",T:9}]),DC=I.makeMessageType("livekit.ParticipantPermission",()=>[{no:1,name:"can_subscribe",kind:"scalar",T:8},{no:2,name:"can_publish",kind:"scalar",T:8},{no:3,name:"can_publish_data",kind:"scalar",T:8},{no:9,name:"can_publish_sources",kind:"enum",T:I.getEnumType(ot),repeated:!0},{no:7,name:"hidden",kind:"scalar",T:8},{no:8,name:"recorder",kind:"scalar",T:8},{no:10,name:"can_update_metadata",kind:"scalar",T:8},{no:11,name:"agent",kind:"scalar",T:8},{no:12,name:"can_subscribe_metrics",kind:"scalar",T:8}]),zs=I.makeMessageType("livekit.ParticipantInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"identity",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:I.getEnumType(Hd)},{no:4,name:"tracks",kind:"message",T:cr,repeated:!0},{no:5,name:"metadata",kind:"scalar",T:9},{no:6,name:"joined_at",kind:"scalar",T:3},{no:17,name:"joined_at_ms",kind:"scalar",T:3},{no:9,name:"name",kind:"scalar",T:9},{no:10,name:"version",kind:"scalar",T:13},{no:11,name:"permission",kind:"message",T:DC},{no:12,name:"region",kind:"scalar",T:9},{no:13,name:"is_publisher",kind:"scalar",T:8},{no:14,name:"kind",kind:"enum",T:I.getEnumType(qs)},{no:15,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:16,name:"disconnect_reason",kind:"enum",T:I.getEnumType(pn)}]),Hd=I.makeEnum("livekit.ParticipantInfo.State",[{no:0,name:"JOINING"},{no:1,name:"JOINED"},{no:2,name:"ACTIVE"},{no:3,name:"DISCONNECTED"}]),qs=I.makeEnum("livekit.ParticipantInfo.Kind",[{no:0,name:"STANDARD"},{no:1,name:"INGRESS"},{no:2,name:"EGRESS"},{no:3,name:"SIP"},{no:4,name:"AGENT"}]),Vt=I.makeEnum("livekit.Encryption.Type",[{no:0,name:"NONE"},{no:1,name:"GCM"},{no:2,name:"CUSTOM"}]),AC=I.makeMessageType("livekit.SimulcastCodecInfo",()=>[{no:1,name:"mime_type",kind:"scalar",T:9},{no:2,name:"mid",kind:"scalar",T:9},{no:3,name:"cid",kind:"scalar",T:9},{no:4,name:"layers",kind:"message",T:pa,repeated:!0}]),cr=I.makeMessageType("livekit.TrackInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"type",kind:"enum",T:I.getEnumType(hn)},{no:3,name:"name",kind:"scalar",T:9},{no:4,name:"muted",kind:"scalar",T:8},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"simulcast",kind:"scalar",T:8},{no:8,name:"disable_dtx",kind:"scalar",T:8},{no:9,name:"source",kind:"enum",T:I.getEnumType(ot)},{no:10,name:"layers",kind:"message",T:pa,repeated:!0},{no:11,name:"mime_type",kind:"scalar",T:9},{no:12,name:"mid",kind:"scalar",T:9},{no:13,name:"codecs",kind:"message",T:AC,repeated:!0},{no:14,name:"stereo",kind:"scalar",T:8},{no:15,name:"disable_red",kind:"scalar",T:8},{no:16,name:"encryption",kind:"enum",T:I.getEnumType(Vt)},{no:17,name:"stream",kind:"scalar",T:9},{no:18,name:"version",kind:"message",T:Q0},{no:19,name:"audio_features",kind:"enum",T:I.getEnumType(On),repeated:!0},{no:20,name:"backup_codec_policy",kind:"enum",T:I.getEnumType(L0)}]),pa=I.makeMessageType("livekit.VideoLayer",()=>[{no:1,name:"quality",kind:"enum",T:I.getEnumType(Nf)},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13},{no:4,name:"bitrate",kind:"scalar",T:13},{no:5,name:"ssrc",kind:"scalar",T:13}]),Mt=I.makeMessageType("livekit.DataPacket",()=>[{no:1,name:"kind",kind:"enum",T:I.getEnumType(_e)},{no:4,name:"participant_identity",kind:"scalar",T:9},{no:5,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:2,name:"user",kind:"message",T:j0,oneof:"value"},{no:3,name:"speaker",kind:"message",T:MC,oneof:"value"},{no:6,name:"sip_dtmf",kind:"message",T:B0,oneof:"value"},{no:7,name:"transcription",kind:"message",T:PC,oneof:"value"},{no:8,name:"metrics",kind:"message",T:EC,oneof:"value"},{no:9,name:"chat_message",kind:"message",T:Gd,oneof:"value"},{no:10,name:"rpc_request",kind:"message",T:z0,oneof:"value"},{no:11,name:"rpc_ack",kind:"message",T:q0,oneof:"value"},{no:12,name:"rpc_response",kind:"message",T:V0,oneof:"value"},{no:13,name:"stream_header",kind:"message",T:Yd,oneof:"value"},{no:14,name:"stream_chunk",kind:"message",T:Kd,oneof:"value"},{no:15,name:"stream_trailer",kind:"message",T:Qd,oneof:"value"}]),_e=I.makeEnum("livekit.DataPacket.Kind",[{no:0,name:"RELIABLE"},{no:1,name:"LOSSY"}]),MC=I.makeMessageType("livekit.ActiveSpeakerUpdate",()=>[{no:1,name:"speakers",kind:"message",T:I0,repeated:!0}]),I0=I.makeMessageType("livekit.SpeakerInfo",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"level",kind:"scalar",T:2},{no:3,name:"active",kind:"scalar",T:8}]),j0=I.makeMessageType("livekit.UserPacket",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:5,name:"participant_identity",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:12},{no:3,name:"destination_sids",kind:"scalar",T:9,repeated:!0},{no:6,name:"destination_identities",kind:"scalar",T:9,repeated:!0},{no:4,name:"topic",kind:"scalar",T:9,opt:!0},{no:8,name:"id",kind:"scalar",T:9,opt:!0},{no:9,name:"start_time",kind:"scalar",T:4,opt:!0},{no:10,name:"end_time",kind:"scalar",T:4,opt:!0},{no:11,name:"nonce",kind:"scalar",T:12}]),B0=I.makeMessageType("livekit.SipDTMF",()=>[{no:3,name:"code",kind:"scalar",T:13},{no:4,name:"digit",kind:"scalar",T:9}]),PC=I.makeMessageType("livekit.Transcription",()=>[{no:2,name:"transcribed_participant_identity",kind:"scalar",T:9},{no:3,name:"track_id",kind:"scalar",T:9},{no:4,name:"segments",kind:"message",T:xC,repeated:!0}]),xC=I.makeMessageType("livekit.TranscriptionSegment",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"start_time",kind:"scalar",T:4},{no:4,name:"end_time",kind:"scalar",T:4},{no:5,name:"final",kind:"scalar",T:8},{no:6,name:"language",kind:"scalar",T:9}]),Gd=I.makeMessageType("livekit.ChatMessage",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"edit_timestamp",kind:"scalar",T:3,opt:!0},{no:4,name:"message",kind:"scalar",T:9},{no:5,name:"deleted",kind:"scalar",T:8},{no:6,name:"generated",kind:"scalar",T:8}]),z0=I.makeMessageType("livekit.RpcRequest",()=>[{no:1,name:"id",kind:"scalar",T:9},{no:2,name:"method",kind:"scalar",T:9},{no:3,name:"payload",kind:"scalar",T:9},{no:4,name:"response_timeout_ms",kind:"scalar",T:13},{no:5,name:"version",kind:"scalar",T:13}]),q0=I.makeMessageType("livekit.RpcAck",()=>[{no:1,name:"request_id",kind:"scalar",T:9}]),V0=I.makeMessageType("livekit.RpcResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:9},{no:2,name:"payload",kind:"scalar",T:9,oneof:"value"},{no:3,name:"error",kind:"message",T:H0,oneof:"value"}]),H0=I.makeMessageType("livekit.RpcError",()=>[{no:1,name:"code",kind:"scalar",T:13},{no:2,name:"message",kind:"scalar",T:9},{no:3,name:"data",kind:"scalar",T:9}]),G0=I.makeMessageType("livekit.ParticipantTracks",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sids",kind:"scalar",T:9,repeated:!0}]),NC=I.makeMessageType("livekit.ServerInfo",()=>[{no:1,name:"edition",kind:"enum",T:I.getEnumType(F0)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"region",kind:"scalar",T:9},{no:5,name:"node_id",kind:"scalar",T:9},{no:6,name:"debug_info",kind:"scalar",T:9},{no:7,name:"agent_protocol",kind:"scalar",T:5}]),F0=I.makeEnum("livekit.ServerInfo.Edition",[{no:0,name:"Standard"},{no:1,name:"Cloud"}]),UC=I.makeMessageType("livekit.ClientInfo",()=>[{no:1,name:"sdk",kind:"enum",T:I.getEnumType(Y0)},{no:2,name:"version",kind:"scalar",T:9},{no:3,name:"protocol",kind:"scalar",T:5},{no:4,name:"os",kind:"scalar",T:9},{no:5,name:"os_version",kind:"scalar",T:9},{no:6,name:"device_model",kind:"scalar",T:9},{no:7,name:"browser",kind:"scalar",T:9},{no:8,name:"browser_version",kind:"scalar",T:9},{no:9,name:"address",kind:"scalar",T:9},{no:10,name:"network",kind:"scalar",T:9},{no:11,name:"other_sdks",kind:"scalar",T:9}]),Y0=I.makeEnum("livekit.ClientInfo.SDK",[{no:0,name:"UNKNOWN"},{no:1,name:"JS"},{no:2,name:"SWIFT"},{no:3,name:"ANDROID"},{no:4,name:"FLUTTER"},{no:5,name:"GO"},{no:6,name:"UNITY"},{no:7,name:"REACT_NATIVE"},{no:8,name:"RUST"},{no:9,name:"PYTHON"},{no:10,name:"CPP"},{no:11,name:"UNITY_WEB"},{no:12,name:"NODE"}]),K0=I.makeMessageType("livekit.ClientConfiguration",()=>[{no:1,name:"video",kind:"message",T:mv},{no:2,name:"screen",kind:"message",T:mv},{no:3,name:"resume_connection",kind:"enum",T:I.getEnumType(Bs)},{no:4,name:"disabled_codecs",kind:"message",T:LC},{no:5,name:"force_relay",kind:"enum",T:I.getEnumType(Bs)}]),mv=I.makeMessageType("livekit.VideoConfiguration",()=>[{no:1,name:"hardware_encoder",kind:"enum",T:I.getEnumType(Bs)}]),LC=I.makeMessageType("livekit.DisabledCodecs",()=>[{no:1,name:"codecs",kind:"message",T:xc,repeated:!0},{no:2,name:"publish",kind:"message",T:xc,repeated:!0}]),Q0=I.makeMessageType("livekit.TimedVersion",()=>[{no:1,name:"unix_micro",kind:"scalar",T:3},{no:2,name:"ticks",kind:"scalar",T:5}]),Fd=I.makeEnum("livekit.DataStream.OperationType",[{no:0,name:"CREATE"},{no:1,name:"UPDATE"},{no:2,name:"DELETE"},{no:3,name:"REACTION"}]),X0=I.makeMessageType("livekit.DataStream.TextHeader",()=>[{no:1,name:"operation_type",kind:"enum",T:I.getEnumType(Fd)},{no:2,name:"version",kind:"scalar",T:5},{no:3,name:"reply_to_stream_id",kind:"scalar",T:9},{no:4,name:"attached_stream_ids",kind:"scalar",T:9,repeated:!0},{no:5,name:"generated",kind:"scalar",T:8}],{localName:"DataStream_TextHeader"}),Z0=I.makeMessageType("livekit.DataStream.ByteHeader",()=>[{no:1,name:"name",kind:"scalar",T:9}],{localName:"DataStream_ByteHeader"}),Yd=I.makeMessageType("livekit.DataStream.Header",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"timestamp",kind:"scalar",T:3},{no:3,name:"topic",kind:"scalar",T:9},{no:4,name:"mime_type",kind:"scalar",T:9},{no:5,name:"total_length",kind:"scalar",T:4,opt:!0},{no:7,name:"encryption_type",kind:"enum",T:I.getEnumType(Vt)},{no:8,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:9,name:"text_header",kind:"message",T:X0,oneof:"content_header"},{no:10,name:"byte_header",kind:"message",T:Z0,oneof:"content_header"}],{localName:"DataStream_Header"}),Kd=I.makeMessageType("livekit.DataStream.Chunk",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"chunk_index",kind:"scalar",T:4},{no:3,name:"content",kind:"scalar",T:12},{no:4,name:"version",kind:"scalar",T:5},{no:5,name:"iv",kind:"scalar",T:12,opt:!0}],{localName:"DataStream_Chunk"}),Qd=I.makeMessageType("livekit.DataStream.Trailer",()=>[{no:1,name:"stream_id",kind:"scalar",T:9},{no:2,name:"reason",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}}],{localName:"DataStream_Trailer"}),mn=I.makeEnum("livekit.SignalTarget",[{no:0,name:"PUBLISHER"},{no:1,name:"SUBSCRIBER"}]),Xd=I.makeEnum("livekit.StreamState",[{no:0,name:"ACTIVE"},{no:1,name:"PAUSED"}]),IC=I.makeEnum("livekit.CandidateProtocol",[{no:0,name:"UDP"},{no:1,name:"TCP"},{no:2,name:"TLS"}]),jC=I.makeMessageType("livekit.SignalRequest",()=>[{no:1,name:"offer",kind:"message",T:va,oneof:"message"},{no:2,name:"answer",kind:"message",T:va,oneof:"message"},{no:3,name:"trickle",kind:"message",T:Lf,oneof:"message"},{no:4,name:"add_track",kind:"message",T:Jd,oneof:"message"},{no:5,name:"mute",kind:"message",T:If,oneof:"message"},{no:6,name:"subscription",kind:"message",T:Fc,oneof:"message"},{no:7,name:"track_setting",kind:"message",T:J0,oneof:"message"},{no:8,name:"leave",kind:"message",T:Yc,oneof:"message"},{no:10,name:"update_layers",kind:"message",T:$0,oneof:"message"},{no:11,name:"subscription_permission",kind:"message",T:iy,oneof:"message"},{no:12,name:"sync_state",kind:"message",T:ay,oneof:"message"},{no:13,name:"simulate",kind:"message",T:_n,oneof:"message"},{no:14,name:"ping",kind:"scalar",T:3,oneof:"message"},{no:15,name:"update_metadata",kind:"message",T:ey,oneof:"message"},{no:16,name:"ping_req",kind:"message",T:sy,oneof:"message"},{no:17,name:"update_audio_track",kind:"message",T:W0,oneof:"message"},{no:18,name:"update_video_track",kind:"message",T:HC,oneof:"message"}]),pv=I.makeMessageType("livekit.SignalResponse",()=>[{no:1,name:"join",kind:"message",T:BC,oneof:"message"},{no:2,name:"answer",kind:"message",T:va,oneof:"message"},{no:3,name:"offer",kind:"message",T:va,oneof:"message"},{no:4,name:"trickle",kind:"message",T:Lf,oneof:"message"},{no:5,name:"update",kind:"message",T:VC,oneof:"message"},{no:6,name:"track_published",kind:"message",T:jf,oneof:"message"},{no:8,name:"leave",kind:"message",T:Yc,oneof:"message"},{no:9,name:"mute",kind:"message",T:If,oneof:"message"},{no:10,name:"speakers_changed",kind:"message",T:GC,oneof:"message"},{no:11,name:"room_update",kind:"message",T:FC,oneof:"message"},{no:12,name:"connection_quality",kind:"message",T:KC,oneof:"message"},{no:13,name:"stream_state_update",kind:"message",T:XC,oneof:"message"},{no:14,name:"subscribed_quality_update",kind:"message",T:JC,oneof:"message"},{no:15,name:"subscription_permission_update",kind:"message",T:WC,oneof:"message"},{no:16,name:"refresh_token",kind:"scalar",T:9,oneof:"message"},{no:17,name:"track_unpublished",kind:"message",T:qC,oneof:"message"},{no:18,name:"pong",kind:"scalar",T:3,oneof:"message"},{no:19,name:"reconnect",kind:"message",T:zC,oneof:"message"},{no:20,name:"pong_resp",kind:"message",T:$C,oneof:"message"},{no:21,name:"subscription_response",kind:"message",T:nE,oneof:"message"},{no:22,name:"request_response",kind:"message",T:iE,oneof:"message"},{no:23,name:"track_subscribed",kind:"message",T:aE,oneof:"message"}]),Zd=I.makeMessageType("livekit.SimulcastCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"cid",kind:"scalar",T:9}]),Jd=I.makeMessageType("livekit.AddTrackRequest",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"type",kind:"enum",T:I.getEnumType(hn)},{no:4,name:"width",kind:"scalar",T:13},{no:5,name:"height",kind:"scalar",T:13},{no:6,name:"muted",kind:"scalar",T:8},{no:7,name:"disable_dtx",kind:"scalar",T:8},{no:8,name:"source",kind:"enum",T:I.getEnumType(ot)},{no:9,name:"layers",kind:"message",T:pa,repeated:!0},{no:10,name:"simulcast_codecs",kind:"message",T:Zd,repeated:!0},{no:11,name:"sid",kind:"scalar",T:9},{no:12,name:"stereo",kind:"scalar",T:8},{no:13,name:"disable_red",kind:"scalar",T:8},{no:14,name:"encryption",kind:"enum",T:I.getEnumType(Vt)},{no:15,name:"stream",kind:"scalar",T:9},{no:16,name:"backup_codec_policy",kind:"enum",T:I.getEnumType(L0)}]),Lf=I.makeMessageType("livekit.TrickleRequest",()=>[{no:1,name:"candidateInit",kind:"scalar",T:9},{no:2,name:"target",kind:"enum",T:I.getEnumType(mn)},{no:3,name:"final",kind:"scalar",T:8}]),If=I.makeMessageType("livekit.MuteTrackRequest",()=>[{no:1,name:"sid",kind:"scalar",T:9},{no:2,name:"muted",kind:"scalar",T:8}]),BC=I.makeMessageType("livekit.JoinResponse",()=>[{no:1,name:"room",kind:"message",T:Uf},{no:2,name:"participant",kind:"message",T:zs},{no:3,name:"other_participants",kind:"message",T:zs,repeated:!0},{no:4,name:"server_version",kind:"scalar",T:9},{no:5,name:"ice_servers",kind:"message",T:ty,repeated:!0},{no:6,name:"subscriber_primary",kind:"scalar",T:8},{no:7,name:"alternative_url",kind:"scalar",T:9},{no:8,name:"client_configuration",kind:"message",T:K0},{no:9,name:"server_region",kind:"scalar",T:9},{no:10,name:"ping_timeout",kind:"scalar",T:5},{no:11,name:"ping_interval",kind:"scalar",T:5},{no:12,name:"server_info",kind:"message",T:NC},{no:13,name:"sif_trailer",kind:"scalar",T:12},{no:14,name:"enabled_publish_codecs",kind:"message",T:xc,repeated:!0},{no:15,name:"fast_publish",kind:"scalar",T:8}]),zC=I.makeMessageType("livekit.ReconnectResponse",()=>[{no:1,name:"ice_servers",kind:"message",T:ty,repeated:!0},{no:2,name:"client_configuration",kind:"message",T:K0}]),jf=I.makeMessageType("livekit.TrackPublishedResponse",()=>[{no:1,name:"cid",kind:"scalar",T:9},{no:2,name:"track",kind:"message",T:cr}]),qC=I.makeMessageType("livekit.TrackUnpublishedResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]),va=I.makeMessageType("livekit.SessionDescription",()=>[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"sdp",kind:"scalar",T:9}]),VC=I.makeMessageType("livekit.ParticipantUpdate",()=>[{no:1,name:"participants",kind:"message",T:zs,repeated:!0}]),Fc=I.makeMessageType("livekit.UpdateSubscription",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:2,name:"subscribe",kind:"scalar",T:8},{no:3,name:"participant_tracks",kind:"message",T:G0,repeated:!0}]),J0=I.makeMessageType("livekit.UpdateTrackSettings",()=>[{no:1,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:3,name:"disabled",kind:"scalar",T:8},{no:4,name:"quality",kind:"enum",T:I.getEnumType(Nf)},{no:5,name:"width",kind:"scalar",T:13},{no:6,name:"height",kind:"scalar",T:13},{no:7,name:"fps",kind:"scalar",T:13},{no:8,name:"priority",kind:"scalar",T:13}]),W0=I.makeMessageType("livekit.UpdateLocalAudioTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"features",kind:"enum",T:I.getEnumType(On),repeated:!0}]),HC=I.makeMessageType("livekit.UpdateLocalVideoTrack",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"width",kind:"scalar",T:13},{no:3,name:"height",kind:"scalar",T:13}]),Yc=I.makeMessageType("livekit.LeaveRequest",()=>[{no:1,name:"can_reconnect",kind:"scalar",T:8},{no:2,name:"reason",kind:"enum",T:I.getEnumType(pn)},{no:3,name:"action",kind:"enum",T:I.getEnumType(ur)},{no:4,name:"regions",kind:"message",T:eE}]),ur=I.makeEnum("livekit.LeaveRequest.Action",[{no:0,name:"DISCONNECT"},{no:1,name:"RESUME"},{no:2,name:"RECONNECT"}]),$0=I.makeMessageType("livekit.UpdateVideoLayers",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"layers",kind:"message",T:pa,repeated:!0}]),ey=I.makeMessageType("livekit.UpdateParticipantMetadata",()=>[{no:1,name:"metadata",kind:"scalar",T:9},{no:2,name:"name",kind:"scalar",T:9},{no:3,name:"attributes",kind:"map",K:9,V:{kind:"scalar",T:9}},{no:4,name:"request_id",kind:"scalar",T:13}]),ty=I.makeMessageType("livekit.ICEServer",()=>[{no:1,name:"urls",kind:"scalar",T:9,repeated:!0},{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"credential",kind:"scalar",T:9}]),GC=I.makeMessageType("livekit.SpeakersChanged",()=>[{no:1,name:"speakers",kind:"message",T:I0,repeated:!0}]),FC=I.makeMessageType("livekit.RoomUpdate",()=>[{no:1,name:"room",kind:"message",T:Uf}]),YC=I.makeMessageType("livekit.ConnectionQualityInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"quality",kind:"enum",T:I.getEnumType(xs)},{no:3,name:"score",kind:"scalar",T:2}]),KC=I.makeMessageType("livekit.ConnectionQualityUpdate",()=>[{no:1,name:"updates",kind:"message",T:YC,repeated:!0}]),QC=I.makeMessageType("livekit.StreamStateInfo",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"state",kind:"enum",T:I.getEnumType(Xd)}]),XC=I.makeMessageType("livekit.StreamStateUpdate",()=>[{no:1,name:"stream_states",kind:"message",T:QC,repeated:!0}]),Bf=I.makeMessageType("livekit.SubscribedQuality",()=>[{no:1,name:"quality",kind:"enum",T:I.getEnumType(Nf)},{no:2,name:"enabled",kind:"scalar",T:8}]),ZC=I.makeMessageType("livekit.SubscribedCodec",()=>[{no:1,name:"codec",kind:"scalar",T:9},{no:2,name:"qualities",kind:"message",T:Bf,repeated:!0}]),JC=I.makeMessageType("livekit.SubscribedQualityUpdate",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"subscribed_qualities",kind:"message",T:Bf,repeated:!0},{no:3,name:"subscribed_codecs",kind:"message",T:ZC,repeated:!0}]),ny=I.makeMessageType("livekit.TrackPermission",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"all_tracks",kind:"scalar",T:8},{no:3,name:"track_sids",kind:"scalar",T:9,repeated:!0},{no:4,name:"participant_identity",kind:"scalar",T:9}]),iy=I.makeMessageType("livekit.SubscriptionPermission",()=>[{no:1,name:"all_participants",kind:"scalar",T:8},{no:2,name:"track_permissions",kind:"message",T:ny,repeated:!0}]),WC=I.makeMessageType("livekit.SubscriptionPermissionUpdate",()=>[{no:1,name:"participant_sid",kind:"scalar",T:9},{no:2,name:"track_sid",kind:"scalar",T:9},{no:3,name:"allowed",kind:"scalar",T:8}]),ay=I.makeMessageType("livekit.SyncState",()=>[{no:1,name:"answer",kind:"message",T:va},{no:2,name:"subscription",kind:"message",T:Fc},{no:3,name:"publish_tracks",kind:"message",T:jf,repeated:!0},{no:4,name:"data_channels",kind:"message",T:ry,repeated:!0},{no:5,name:"offer",kind:"message",T:va},{no:6,name:"track_sids_disabled",kind:"scalar",T:9,repeated:!0}]),ry=I.makeMessageType("livekit.DataChannelInfo",()=>[{no:1,name:"label",kind:"scalar",T:9},{no:2,name:"id",kind:"scalar",T:13},{no:3,name:"target",kind:"enum",T:I.getEnumType(mn)}]),_n=I.makeMessageType("livekit.SimulateScenario",()=>[{no:1,name:"speaker_update",kind:"scalar",T:5,oneof:"scenario"},{no:2,name:"node_failure",kind:"scalar",T:8,oneof:"scenario"},{no:3,name:"migration",kind:"scalar",T:8,oneof:"scenario"},{no:4,name:"server_leave",kind:"scalar",T:8,oneof:"scenario"},{no:5,name:"switch_candidate_protocol",kind:"enum",T:I.getEnumType(IC),oneof:"scenario"},{no:6,name:"subscriber_bandwidth",kind:"scalar",T:3,oneof:"scenario"},{no:7,name:"disconnect_signal_on_resume",kind:"scalar",T:8,oneof:"scenario"},{no:8,name:"disconnect_signal_on_resume_no_messages",kind:"scalar",T:8,oneof:"scenario"},{no:9,name:"leave_request_full_reconnect",kind:"scalar",T:8,oneof:"scenario"}]),sy=I.makeMessageType("livekit.Ping",()=>[{no:1,name:"timestamp",kind:"scalar",T:3},{no:2,name:"rtt",kind:"scalar",T:3}]),$C=I.makeMessageType("livekit.Pong",()=>[{no:1,name:"last_ping_timestamp",kind:"scalar",T:3},{no:2,name:"timestamp",kind:"scalar",T:3}]),eE=I.makeMessageType("livekit.RegionSettings",()=>[{no:1,name:"regions",kind:"message",T:tE,repeated:!0}]),tE=I.makeMessageType("livekit.RegionInfo",()=>[{no:1,name:"region",kind:"scalar",T:9},{no:2,name:"url",kind:"scalar",T:9},{no:3,name:"distance",kind:"scalar",T:3}]),nE=I.makeMessageType("livekit.SubscriptionResponse",()=>[{no:1,name:"track_sid",kind:"scalar",T:9},{no:2,name:"err",kind:"enum",T:I.getEnumType(OC)}]),iE=I.makeMessageType("livekit.RequestResponse",()=>[{no:1,name:"request_id",kind:"scalar",T:13},{no:2,name:"reason",kind:"enum",T:I.getEnumType(zf)},{no:3,name:"message",kind:"scalar",T:9}]),zf=I.makeEnum("livekit.RequestResponse.Reason",[{no:0,name:"OK"},{no:1,name:"NOT_FOUND"},{no:2,name:"NOT_ALLOWED"},{no:3,name:"LIMIT_EXCEEDED"}]),aE=I.makeMessageType("livekit.TrackSubscribed",()=>[{no:1,name:"track_sid",kind:"scalar",T:9}]);function rE(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var Sc={exports:{}},sE=Sc.exports,gv;function oE(){return gv||(gv=1,function(a){(function(e,n){a.exports?a.exports=n():e.log=n()})(sE,function(){var e=function(){},n="undefined",r=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],l={},u=null;function d(k,w){var O=k[w];if(typeof O.bind=="function")return O.bind(k);try{return Function.prototype.bind.call(O,k)}catch{return function(){return Function.prototype.apply.apply(O,[k,arguments])}}}function h(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function m(k){return k==="debug"&&(k="log"),typeof console===n?!1:k==="trace"&&r?h:console[k]!==void 0?d(console,k):console.log!==void 0?d(console,"log"):e}function g(){for(var k=this.getLevel(),w=0;w<o.length;w++){var O=o[w];this[O]=w<k?e:this.methodFactory(O,k,this.name)}if(this.log=this.debug,typeof console===n&&k<this.levels.SILENT)return"No console available for logging"}function y(k){return function(){typeof console!==n&&(g.call(this),this[k].apply(this,arguments))}}function b(k,w,O){return m(k)||y.apply(this,arguments)}function T(k,w){var O=this,V,Q,U,_="loglevel";typeof k=="string"?_+=":"+k:typeof k=="symbol"&&(_=void 0);function H(ee){var oe=(o[ee]||"silent").toUpperCase();if(!(typeof window===n||!_)){try{window.localStorage[_]=oe;return}catch{}try{window.document.cookie=encodeURIComponent(_)+"="+oe+";"}catch{}}}function $(){var ee;if(!(typeof window===n||!_)){try{ee=window.localStorage[_]}catch{}if(typeof ee===n)try{var oe=window.document.cookie,qe=encodeURIComponent(_),Fe=oe.indexOf(qe+"=");Fe!==-1&&(ee=/^([^;]+)/.exec(oe.slice(Fe+qe.length+1))[1])}catch{}return O.levels[ee]===void 0&&(ee=void 0),ee}}function ie(){if(!(typeof window===n||!_)){try{window.localStorage.removeItem(_)}catch{}try{window.document.cookie=encodeURIComponent(_)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function X(ee){var oe=ee;if(typeof oe=="string"&&O.levels[oe.toUpperCase()]!==void 0&&(oe=O.levels[oe.toUpperCase()]),typeof oe=="number"&&oe>=0&&oe<=O.levels.SILENT)return oe;throw new TypeError("log.setLevel() called with invalid level: "+ee)}O.name=k,O.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},O.methodFactory=w||b,O.getLevel=function(){return U??Q??V},O.setLevel=function(ee,oe){return U=X(ee),oe!==!1&&H(U),g.call(O)},O.setDefaultLevel=function(ee){Q=X(ee),$()||O.setLevel(ee,!1)},O.resetLevel=function(){U=null,ie(),g.call(O)},O.enableAll=function(ee){O.setLevel(O.levels.TRACE,ee)},O.disableAll=function(ee){O.setLevel(O.levels.SILENT,ee)},O.rebuild=function(){if(u!==O&&(V=X(u.getLevel())),g.call(O),u===O)for(var ee in l)l[ee].rebuild()},V=X(u?u.getLevel():"WARN");var J=$();J!=null&&(U=X(J)),g.call(O)}u=new T,u.getLogger=function(w){if(typeof w!="symbol"&&typeof w!="string"||w==="")throw new TypeError("You must supply a name when creating a logger.");var O=l[w];return O||(O=l[w]=new T(w,u.methodFactory)),O};var C=typeof window!==n?window.log:void 0;return u.noConflict=function(){return typeof window!==n&&window.log===u&&(window.log=C),u},u.getLoggers=function(){return l},u.default=u,u})}(Sc)),Sc.exports}var Kc=oE(),Wd;(function(a){a[a.trace=0]="trace",a[a.debug=1]="debug",a[a.info=2]="info",a[a.warn=3]="warn",a[a.error=4]="error",a[a.silent=5]="silent"})(Wd||(Wd={}));var gn;(function(a){a.Default="livekit",a.Room="livekit-room",a.Participant="livekit-participant",a.Track="livekit-track",a.Publication="livekit-track-publication",a.Engine="livekit-engine",a.Signal="livekit-signal",a.PCManager="livekit-pc-manager",a.PCTransport="livekit-pc-transport",a.E2EE="lk-e2ee"})(gn||(gn={}));let ke=Kc.getLogger("livekit");Object.values(gn).map(a=>Kc.getLogger(a));ke.setDefaultLevel(Wd.info);function ei(a){const e=Kc.getLogger(a);return e.setDefaultLevel(ke.getLevel()),e}const cE=Kc.getLogger("lk-e2ee"),Os=7e3,lE=[0,300,2*2*300,3*3*300,4*4*300,Os,Os,Os,Os,Os];class uE{constructor(e){this._retryDelays=e!==void 0?[...e]:lE}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;const n=this._retryDelays[e.retryCount];return e.retryCount<=1?n:n+Math.random()*1e3}}function dE(a,e){var n={};for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&e.indexOf(r)<0&&(n[r]=a[r]);if(a!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(a);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(a,r[o])&&(n[r[o]]=a[r[o]]);return n}function R(a,e,n,r){function o(l){return l instanceof n?l:new n(function(u){u(l)})}return new(n||(n=Promise))(function(l,u){function d(g){try{m(r.next(g))}catch(y){u(y)}}function h(g){try{m(r.throw(g))}catch(y){u(y)}}function m(g){g.done?l(g.value):o(g.value).then(d,h)}m((r=r.apply(a,e||[])).next())})}function vv(a){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&a[e],r=0;if(n)return n.call(a);if(a&&typeof a.length=="number")return{next:function(){return a&&r>=a.length&&(a=void 0),{value:a&&a[r++],done:!a}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function xi(a){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=a[Symbol.asyncIterator],n;return e?e.call(a):(a=typeof vv=="function"?vv(a):a[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(l){n[l]=a[l]&&function(u){return new Promise(function(d,h){u=a[l](u),o(d,h,u.done,u.value)})}}function o(l,u,d,h){Promise.resolve(h).then(function(m){l({value:m,done:d})},u)}}var dc={exports:{}},yv;function fE(){if(yv)return dc.exports;yv=1;var a=typeof Reflect=="object"?Reflect:null,e=a&&typeof a.apply=="function"?a.apply:function(_,H,$){return Function.prototype.apply.call(_,H,$)},n;a&&typeof a.ownKeys=="function"?n=a.ownKeys:Object.getOwnPropertySymbols?n=function(_){return Object.getOwnPropertyNames(_).concat(Object.getOwnPropertySymbols(_))}:n=function(_){return Object.getOwnPropertyNames(_)};function r(U){console&&console.warn&&console.warn(U)}var o=Number.isNaN||function(_){return _!==_};function l(){l.init.call(this)}dc.exports=l,dc.exports.once=O,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var u=10;function d(U){if(typeof U!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof U)}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return u},set:function(U){if(typeof U!="number"||U<0||o(U))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+U+".");u=U}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(_){if(typeof _!="number"||_<0||o(_))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+_+".");return this._maxListeners=_,this};function h(U){return U._maxListeners===void 0?l.defaultMaxListeners:U._maxListeners}l.prototype.getMaxListeners=function(){return h(this)},l.prototype.emit=function(_){for(var H=[],$=1;$<arguments.length;$++)H.push(arguments[$]);var ie=_==="error",X=this._events;if(X!==void 0)ie=ie&&X.error===void 0;else if(!ie)return!1;if(ie){var J;if(H.length>0&&(J=H[0]),J instanceof Error)throw J;var ee=new Error("Unhandled error."+(J?" ("+J.message+")":""));throw ee.context=J,ee}var oe=X[_];if(oe===void 0)return!1;if(typeof oe=="function")e(oe,this,H);else for(var qe=oe.length,Fe=C(oe,qe),$=0;$<qe;++$)e(Fe[$],this,H);return!0};function m(U,_,H,$){var ie,X,J;if(d(H),X=U._events,X===void 0?(X=U._events=Object.create(null),U._eventsCount=0):(X.newListener!==void 0&&(U.emit("newListener",_,H.listener?H.listener:H),X=U._events),J=X[_]),J===void 0)J=X[_]=H,++U._eventsCount;else if(typeof J=="function"?J=X[_]=$?[H,J]:[J,H]:$?J.unshift(H):J.push(H),ie=h(U),ie>0&&J.length>ie&&!J.warned){J.warned=!0;var ee=new Error("Possible EventEmitter memory leak detected. "+J.length+" "+String(_)+" listeners added. Use emitter.setMaxListeners() to increase limit");ee.name="MaxListenersExceededWarning",ee.emitter=U,ee.type=_,ee.count=J.length,r(ee)}return U}l.prototype.addListener=function(_,H){return m(this,_,H,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(_,H){return m(this,_,H,!0)};function g(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function y(U,_,H){var $={fired:!1,wrapFn:void 0,target:U,type:_,listener:H},ie=g.bind($);return ie.listener=H,$.wrapFn=ie,ie}l.prototype.once=function(_,H){return d(H),this.on(_,y(this,_,H)),this},l.prototype.prependOnceListener=function(_,H){return d(H),this.prependListener(_,y(this,_,H)),this},l.prototype.removeListener=function(_,H){var $,ie,X,J,ee;if(d(H),ie=this._events,ie===void 0)return this;if($=ie[_],$===void 0)return this;if($===H||$.listener===H)--this._eventsCount===0?this._events=Object.create(null):(delete ie[_],ie.removeListener&&this.emit("removeListener",_,$.listener||H));else if(typeof $!="function"){for(X=-1,J=$.length-1;J>=0;J--)if($[J]===H||$[J].listener===H){ee=$[J].listener,X=J;break}if(X<0)return this;X===0?$.shift():k($,X),$.length===1&&(ie[_]=$[0]),ie.removeListener!==void 0&&this.emit("removeListener",_,ee||H)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(_){var H,$,ie;if($=this._events,$===void 0)return this;if($.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):$[_]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete $[_]),this;if(arguments.length===0){var X=Object.keys($),J;for(ie=0;ie<X.length;++ie)J=X[ie],J!=="removeListener"&&this.removeAllListeners(J);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(H=$[_],typeof H=="function")this.removeListener(_,H);else if(H!==void 0)for(ie=H.length-1;ie>=0;ie--)this.removeListener(_,H[ie]);return this};function b(U,_,H){var $=U._events;if($===void 0)return[];var ie=$[_];return ie===void 0?[]:typeof ie=="function"?H?[ie.listener||ie]:[ie]:H?w(ie):C(ie,ie.length)}l.prototype.listeners=function(_){return b(this,_,!0)},l.prototype.rawListeners=function(_){return b(this,_,!1)},l.listenerCount=function(U,_){return typeof U.listenerCount=="function"?U.listenerCount(_):T.call(U,_)},l.prototype.listenerCount=T;function T(U){var _=this._events;if(_!==void 0){var H=_[U];if(typeof H=="function")return 1;if(H!==void 0)return H.length}return 0}l.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function C(U,_){for(var H=new Array(_),$=0;$<_;++$)H[$]=U[$];return H}function k(U,_){for(;_+1<U.length;_++)U[_]=U[_+1];U.pop()}function w(U){for(var _=new Array(U.length),H=0;H<_.length;++H)_[H]=U[H].listener||U[H];return _}function O(U,_){return new Promise(function(H,$){function ie(J){U.removeListener(_,X),$(J)}function X(){typeof U.removeListener=="function"&&U.removeListener("error",ie),H([].slice.call(arguments))}Q(U,_,X,{once:!0}),_!=="error"&&V(U,ie,{once:!0})})}function V(U,_,H){typeof U.on=="function"&&Q(U,"error",_,H)}function Q(U,_,H,$){if(typeof U.on=="function")$.once?U.once(_,H):U.on(_,H);else if(typeof U.addEventListener=="function")U.addEventListener(_,function ie(X){$.once&&U.removeEventListener(_,ie),H(X)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof U)}return dc.exports}var xn=fE();let oy=!0,cy=!0;function Tc(a,e,n){const r=a.match(e);return r&&r.length>=n&&parseInt(r[n],10)}function ba(a,e,n){if(!a.RTCPeerConnection)return;const r=a.RTCPeerConnection.prototype,o=r.addEventListener;r.addEventListener=function(u,d){if(u!==e)return o.apply(this,arguments);const h=m=>{const g=n(m);g&&(d.handleEvent?d.handleEvent(g):d(g))};return this._eventMap=this._eventMap||{},this._eventMap[e]||(this._eventMap[e]=new Map),this._eventMap[e].set(d,h),o.apply(this,[u,h])};const l=r.removeEventListener;r.removeEventListener=function(u,d){if(u!==e||!this._eventMap||!this._eventMap[e])return l.apply(this,arguments);if(!this._eventMap[e].has(d))return l.apply(this,arguments);const h=this._eventMap[e].get(d);return this._eventMap[e].delete(d),this._eventMap[e].size===0&&delete this._eventMap[e],Object.keys(this._eventMap).length===0&&delete this._eventMap,l.apply(this,[u,h])},Object.defineProperty(r,"on"+e,{get(){return this["_on"+e]},set(u){this["_on"+e]&&(this.removeEventListener(e,this["_on"+e]),delete this["_on"+e]),u&&this.addEventListener(e,this["_on"+e]=u)},enumerable:!0,configurable:!0})}function hE(a){return typeof a!="boolean"?new Error("Argument type: "+typeof a+". Please use a boolean."):(oy=a,a?"adapter.js logging disabled":"adapter.js logging enabled")}function mE(a){return typeof a!="boolean"?new Error("Argument type: "+typeof a+". Please use a boolean."):(cy=!a,"adapter.js deprecation warnings "+(a?"disabled":"enabled"))}function ly(){if(typeof window=="object"){if(oy)return;typeof console<"u"&&typeof console.log=="function"&&console.log.apply(console,arguments)}}function qf(a,e){cy&&console.warn(a+" is deprecated, please use "+e+" instead.")}function pE(a){const e={browser:null,version:null};if(typeof a>"u"||!a.navigator||!a.navigator.userAgent)return e.browser="Not a browser.",e;const{navigator:n}=a;if(n.userAgentData&&n.userAgentData.brands){const r=n.userAgentData.brands.find(o=>o.brand==="Chromium");if(r)return{browser:"chrome",version:parseInt(r.version,10)}}if(n.mozGetUserMedia)e.browser="firefox",e.version=Tc(n.userAgent,/Firefox\/(\d+)\./,1);else if(n.webkitGetUserMedia||a.isSecureContext===!1&&a.webkitRTCPeerConnection)e.browser="chrome",e.version=Tc(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2);else if(a.RTCPeerConnection&&n.userAgent.match(/AppleWebKit\/(\d+)\./))e.browser="safari",e.version=Tc(n.userAgent,/AppleWebKit\/(\d+)\./,1),e.supportsUnifiedPlan=a.RTCRtpTransceiver&&"currentDirection"in a.RTCRtpTransceiver.prototype;else return e.browser="Not a supported browser.",e;return e}function bv(a){return Object.prototype.toString.call(a)==="[object Object]"}function uy(a){return bv(a)?Object.keys(a).reduce(function(e,n){const r=bv(a[n]),o=r?uy(a[n]):a[n],l=r&&!Object.keys(o).length;return o===void 0||l?e:Object.assign(e,{[n]:o})},{}):a}function $d(a,e,n){!e||n.has(e.id)||(n.set(e.id,e),Object.keys(e).forEach(r=>{r.endsWith("Id")?$d(a,a.get(e[r]),n):r.endsWith("Ids")&&e[r].forEach(o=>{$d(a,a.get(o),n)})}))}function Sv(a,e,n){const r=n?"outbound-rtp":"inbound-rtp",o=new Map;if(e===null)return o;const l=[];return a.forEach(u=>{u.type==="track"&&u.trackIdentifier===e.id&&l.push(u)}),l.forEach(u=>{a.forEach(d=>{d.type===r&&d.trackId===u.id&&$d(a,d,o)})}),o}const Tv=ly;function dy(a,e){const n=a&&a.navigator;if(!n.mediaDevices)return;const r=function(d){if(typeof d!="object"||d.mandatory||d.optional)return d;const h={};return Object.keys(d).forEach(m=>{if(m==="require"||m==="advanced"||m==="mediaSource")return;const g=typeof d[m]=="object"?d[m]:{ideal:d[m]};g.exact!==void 0&&typeof g.exact=="number"&&(g.min=g.max=g.exact);const y=function(b,T){return b?b+T.charAt(0).toUpperCase()+T.slice(1):T==="deviceId"?"sourceId":T};if(g.ideal!==void 0){h.optional=h.optional||[];let b={};typeof g.ideal=="number"?(b[y("min",m)]=g.ideal,h.optional.push(b),b={},b[y("max",m)]=g.ideal,h.optional.push(b)):(b[y("",m)]=g.ideal,h.optional.push(b))}g.exact!==void 0&&typeof g.exact!="number"?(h.mandatory=h.mandatory||{},h.mandatory[y("",m)]=g.exact):["min","max"].forEach(b=>{g[b]!==void 0&&(h.mandatory=h.mandatory||{},h.mandatory[y(b,m)]=g[b])})}),d.advanced&&(h.optional=(h.optional||[]).concat(d.advanced)),h},o=function(d,h){if(e.version>=61)return h(d);if(d=JSON.parse(JSON.stringify(d)),d&&typeof d.audio=="object"){const m=function(g,y,b){y in g&&!(b in g)&&(g[b]=g[y],delete g[y])};d=JSON.parse(JSON.stringify(d)),m(d.audio,"autoGainControl","googAutoGainControl"),m(d.audio,"noiseSuppression","googNoiseSuppression"),d.audio=r(d.audio)}if(d&&typeof d.video=="object"){let m=d.video.facingMode;m=m&&(typeof m=="object"?m:{ideal:m});const g=e.version<66;if(m&&(m.exact==="user"||m.exact==="environment"||m.ideal==="user"||m.ideal==="environment")&&!(n.mediaDevices.getSupportedConstraints&&n.mediaDevices.getSupportedConstraints().facingMode&&!g)){delete d.video.facingMode;let y;if(m.exact==="environment"||m.ideal==="environment"?y=["back","rear"]:(m.exact==="user"||m.ideal==="user")&&(y=["front"]),y)return n.mediaDevices.enumerateDevices().then(b=>{b=b.filter(C=>C.kind==="videoinput");let T=b.find(C=>y.some(k=>C.label.toLowerCase().includes(k)));return!T&&b.length&&y.includes("back")&&(T=b[b.length-1]),T&&(d.video.deviceId=m.exact?{exact:T.deviceId}:{ideal:T.deviceId}),d.video=r(d.video),Tv("chrome: "+JSON.stringify(d)),h(d)})}d.video=r(d.video)}return Tv("chrome: "+JSON.stringify(d)),h(d)},l=function(d){return e.version>=64?d:{name:{PermissionDeniedError:"NotAllowedError",PermissionDismissedError:"NotAllowedError",InvalidStateError:"NotAllowedError",DevicesNotFoundError:"NotFoundError",ConstraintNotSatisfiedError:"OverconstrainedError",TrackStartError:"NotReadableError",MediaDeviceFailedDueToShutdown:"NotAllowedError",MediaDeviceKillSwitchOn:"NotAllowedError",TabCaptureError:"AbortError",ScreenCaptureError:"AbortError",DeviceCaptureError:"AbortError"}[d.name]||d.name,message:d.message,constraint:d.constraint||d.constraintName,toString(){return this.name+(this.message&&": ")+this.message}}},u=function(d,h,m){o(d,g=>{n.webkitGetUserMedia(g,h,y=>{m&&m(l(y))})})};if(n.getUserMedia=u.bind(n),n.mediaDevices.getUserMedia){const d=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(h){return o(h,m=>d(m).then(g=>{if(m.audio&&!g.getAudioTracks().length||m.video&&!g.getVideoTracks().length)throw g.getTracks().forEach(y=>{y.stop()}),new DOMException("","NotFoundError");return g},g=>Promise.reject(l(g))))}}}function fy(a){a.MediaStream=a.MediaStream||a.webkitMediaStream}function hy(a){if(typeof a=="object"&&a.RTCPeerConnection&&!("ontrack"in a.RTCPeerConnection.prototype)){Object.defineProperty(a.RTCPeerConnection.prototype,"ontrack",{get(){return this._ontrack},set(n){this._ontrack&&this.removeEventListener("track",this._ontrack),this.addEventListener("track",this._ontrack=n)},enumerable:!0,configurable:!0});const e=a.RTCPeerConnection.prototype.setRemoteDescription;a.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=r=>{r.stream.addEventListener("addtrack",o=>{let l;a.RTCPeerConnection.prototype.getReceivers?l=this.getReceivers().find(d=>d.track&&d.track.id===o.track.id):l={track:o.track};const u=new Event("track");u.track=o.track,u.receiver=l,u.transceiver={receiver:l},u.streams=[r.stream],this.dispatchEvent(u)}),r.stream.getTracks().forEach(o=>{let l;a.RTCPeerConnection.prototype.getReceivers?l=this.getReceivers().find(d=>d.track&&d.track.id===o.id):l={track:o};const u=new Event("track");u.track=o,u.receiver=l,u.transceiver={receiver:l},u.streams=[r.stream],this.dispatchEvent(u)})},this.addEventListener("addstream",this._ontrackpoly)),e.apply(this,arguments)}}else ba(a,"track",e=>(e.transceiver||Object.defineProperty(e,"transceiver",{value:{receiver:e.receiver}}),e))}function my(a){if(typeof a=="object"&&a.RTCPeerConnection&&!("getSenders"in a.RTCPeerConnection.prototype)&&"createDTMFSender"in a.RTCPeerConnection.prototype){const e=function(o,l){return{track:l,get dtmf(){return this._dtmf===void 0&&(l.kind==="audio"?this._dtmf=o.createDTMFSender(l):this._dtmf=null),this._dtmf},_pc:o}};if(!a.RTCPeerConnection.prototype.getSenders){a.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};const o=a.RTCPeerConnection.prototype.addTrack;a.RTCPeerConnection.prototype.addTrack=function(d,h){let m=o.apply(this,arguments);return m||(m=e(this,d),this._senders.push(m)),m};const l=a.RTCPeerConnection.prototype.removeTrack;a.RTCPeerConnection.prototype.removeTrack=function(d){l.apply(this,arguments);const h=this._senders.indexOf(d);h!==-1&&this._senders.splice(h,1)}}const n=a.RTCPeerConnection.prototype.addStream;a.RTCPeerConnection.prototype.addStream=function(l){this._senders=this._senders||[],n.apply(this,[l]),l.getTracks().forEach(u=>{this._senders.push(e(this,u))})};const r=a.RTCPeerConnection.prototype.removeStream;a.RTCPeerConnection.prototype.removeStream=function(l){this._senders=this._senders||[],r.apply(this,[l]),l.getTracks().forEach(u=>{const d=this._senders.find(h=>h.track===u);d&&this._senders.splice(this._senders.indexOf(d),1)})}}else if(typeof a=="object"&&a.RTCPeerConnection&&"getSenders"in a.RTCPeerConnection.prototype&&"createDTMFSender"in a.RTCPeerConnection.prototype&&a.RTCRtpSender&&!("dtmf"in a.RTCRtpSender.prototype)){const e=a.RTCPeerConnection.prototype.getSenders;a.RTCPeerConnection.prototype.getSenders=function(){const r=e.apply(this,[]);return r.forEach(o=>o._pc=this),r},Object.defineProperty(a.RTCRtpSender.prototype,"dtmf",{get(){return this._dtmf===void 0&&(this.track.kind==="audio"?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function py(a){if(!(typeof a=="object"&&a.RTCPeerConnection&&a.RTCRtpSender&&a.RTCRtpReceiver))return;if(!("getStats"in a.RTCRtpSender.prototype)){const n=a.RTCPeerConnection.prototype.getSenders;n&&(a.RTCPeerConnection.prototype.getSenders=function(){const l=n.apply(this,[]);return l.forEach(u=>u._pc=this),l});const r=a.RTCPeerConnection.prototype.addTrack;r&&(a.RTCPeerConnection.prototype.addTrack=function(){const l=r.apply(this,arguments);return l._pc=this,l}),a.RTCRtpSender.prototype.getStats=function(){const l=this;return this._pc.getStats().then(u=>Sv(u,l.track,!0))}}if(!("getStats"in a.RTCRtpReceiver.prototype)){const n=a.RTCPeerConnection.prototype.getReceivers;n&&(a.RTCPeerConnection.prototype.getReceivers=function(){const o=n.apply(this,[]);return o.forEach(l=>l._pc=this),o}),ba(a,"track",r=>(r.receiver._pc=r.srcElement,r)),a.RTCRtpReceiver.prototype.getStats=function(){const o=this;return this._pc.getStats().then(l=>Sv(l,o.track,!1))}}if(!("getStats"in a.RTCRtpSender.prototype&&"getStats"in a.RTCRtpReceiver.prototype))return;const e=a.RTCPeerConnection.prototype.getStats;a.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof a.MediaStreamTrack){const r=arguments[0];let o,l,u;return this.getSenders().forEach(d=>{d.track===r&&(o?u=!0:o=d)}),this.getReceivers().forEach(d=>(d.track===r&&(l?u=!0:l=d),d.track===r)),u||o&&l?Promise.reject(new DOMException("There are more than one sender or receiver for the track.","InvalidAccessError")):o?o.getStats():l?l.getStats():Promise.reject(new DOMException("There is no sender or receiver for the track.","InvalidAccessError"))}return e.apply(this,arguments)}}function gy(a){a.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(u=>this._shimmedLocalStreams[u][0])};const e=a.RTCPeerConnection.prototype.addTrack;a.RTCPeerConnection.prototype.addTrack=function(u,d){if(!d)return e.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};const h=e.apply(this,arguments);return this._shimmedLocalStreams[d.id]?this._shimmedLocalStreams[d.id].indexOf(h)===-1&&this._shimmedLocalStreams[d.id].push(h):this._shimmedLocalStreams[d.id]=[d,h],h};const n=a.RTCPeerConnection.prototype.addStream;a.RTCPeerConnection.prototype.addStream=function(u){this._shimmedLocalStreams=this._shimmedLocalStreams||{},u.getTracks().forEach(m=>{if(this.getSenders().find(y=>y.track===m))throw new DOMException("Track already exists.","InvalidAccessError")});const d=this.getSenders();n.apply(this,arguments);const h=this.getSenders().filter(m=>d.indexOf(m)===-1);this._shimmedLocalStreams[u.id]=[u].concat(h)};const r=a.RTCPeerConnection.prototype.removeStream;a.RTCPeerConnection.prototype.removeStream=function(u){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[u.id],r.apply(this,arguments)};const o=a.RTCPeerConnection.prototype.removeTrack;a.RTCPeerConnection.prototype.removeTrack=function(u){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},u&&Object.keys(this._shimmedLocalStreams).forEach(d=>{const h=this._shimmedLocalStreams[d].indexOf(u);h!==-1&&this._shimmedLocalStreams[d].splice(h,1),this._shimmedLocalStreams[d].length===1&&delete this._shimmedLocalStreams[d]}),o.apply(this,arguments)}}function vy(a,e){if(!a.RTCPeerConnection)return;if(a.RTCPeerConnection.prototype.addTrack&&e.version>=65)return gy(a);const n=a.RTCPeerConnection.prototype.getLocalStreams;a.RTCPeerConnection.prototype.getLocalStreams=function(){const g=n.apply(this);return this._reverseStreams=this._reverseStreams||{},g.map(y=>this._reverseStreams[y.id])};const r=a.RTCPeerConnection.prototype.addStream;a.RTCPeerConnection.prototype.addStream=function(g){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},g.getTracks().forEach(y=>{if(this.getSenders().find(T=>T.track===y))throw new DOMException("Track already exists.","InvalidAccessError")}),!this._reverseStreams[g.id]){const y=new a.MediaStream(g.getTracks());this._streams[g.id]=y,this._reverseStreams[y.id]=g,g=y}r.apply(this,[g])};const o=a.RTCPeerConnection.prototype.removeStream;a.RTCPeerConnection.prototype.removeStream=function(g){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},o.apply(this,[this._streams[g.id]||g]),delete this._reverseStreams[this._streams[g.id]?this._streams[g.id].id:g.id],delete this._streams[g.id]},a.RTCPeerConnection.prototype.addTrack=function(g,y){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");const b=[].slice.call(arguments,1);if(b.length!==1||!b[0].getTracks().find(k=>k===g))throw new DOMException("The adapter.js addTrack polyfill only supports a single  stream which is associated with the specified track.","NotSupportedError");if(this.getSenders().find(k=>k.track===g))throw new DOMException("Track already exists.","InvalidAccessError");this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};const C=this._streams[y.id];if(C)C.addTrack(g),Promise.resolve().then(()=>{this.dispatchEvent(new Event("negotiationneeded"))});else{const k=new a.MediaStream([g]);this._streams[y.id]=k,this._reverseStreams[k.id]=y,this.addStream(k)}return this.getSenders().find(k=>k.track===g)};function l(m,g){let y=g.sdp;return Object.keys(m._reverseStreams||[]).forEach(b=>{const T=m._reverseStreams[b],C=m._streams[T.id];y=y.replace(new RegExp(C.id,"g"),T.id)}),new RTCSessionDescription({type:g.type,sdp:y})}function u(m,g){let y=g.sdp;return Object.keys(m._reverseStreams||[]).forEach(b=>{const T=m._reverseStreams[b],C=m._streams[T.id];y=y.replace(new RegExp(T.id,"g"),C.id)}),new RTCSessionDescription({type:g.type,sdp:y})}["createOffer","createAnswer"].forEach(function(m){const g=a.RTCPeerConnection.prototype[m],y={[m](){const b=arguments;return arguments.length&&typeof arguments[0]=="function"?g.apply(this,[C=>{const k=l(this,C);b[0].apply(null,[k])},C=>{b[1]&&b[1].apply(null,C)},arguments[2]]):g.apply(this,arguments).then(C=>l(this,C))}};a.RTCPeerConnection.prototype[m]=y[m]});const d=a.RTCPeerConnection.prototype.setLocalDescription;a.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type?d.apply(this,arguments):(arguments[0]=u(this,arguments[0]),d.apply(this,arguments))};const h=Object.getOwnPropertyDescriptor(a.RTCPeerConnection.prototype,"localDescription");Object.defineProperty(a.RTCPeerConnection.prototype,"localDescription",{get(){const m=h.get.apply(this);return m.type===""?m:l(this,m)}}),a.RTCPeerConnection.prototype.removeTrack=function(g){if(this.signalingState==="closed")throw new DOMException("The RTCPeerConnection's signalingState is 'closed'.","InvalidStateError");if(!g._pc)throw new DOMException("Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.","TypeError");if(!(g._pc===this))throw new DOMException("Sender was not created by this connection.","InvalidAccessError");this._streams=this._streams||{};let b;Object.keys(this._streams).forEach(T=>{this._streams[T].getTracks().find(k=>g.track===k)&&(b=this._streams[T])}),b&&(b.getTracks().length===1?this.removeStream(this._reverseStreams[b.id]):b.removeTrack(g.track),this.dispatchEvent(new Event("negotiationneeded")))}}function ef(a,e){!a.RTCPeerConnection&&a.webkitRTCPeerConnection&&(a.RTCPeerConnection=a.webkitRTCPeerConnection),a.RTCPeerConnection&&e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(n){const r=a.RTCPeerConnection.prototype[n],o={[n](){return arguments[0]=new(n==="addIceCandidate"?a.RTCIceCandidate:a.RTCSessionDescription)(arguments[0]),r.apply(this,arguments)}};a.RTCPeerConnection.prototype[n]=o[n]})}function yy(a,e){ba(a,"negotiationneeded",n=>{const r=n.target;if(!((e.version<72||r.getConfiguration&&r.getConfiguration().sdpSemantics==="plan-b")&&r.signalingState!=="stable"))return n})}var kv=Object.freeze({__proto__:null,fixNegotiationNeeded:yy,shimAddTrackRemoveTrack:vy,shimAddTrackRemoveTrackWithNative:gy,shimGetSendersWithDtmf:my,shimGetUserMedia:dy,shimMediaStream:fy,shimOnTrack:hy,shimPeerConnection:ef,shimSenderReceiverGetStats:py});function by(a,e){const n=a&&a.navigator,r=a&&a.MediaStreamTrack;if(n.getUserMedia=function(o,l,u){qf("navigator.getUserMedia","navigator.mediaDevices.getUserMedia"),n.mediaDevices.getUserMedia(o).then(l,u)},!(e.version>55&&"autoGainControl"in n.mediaDevices.getSupportedConstraints())){const o=function(u,d,h){d in u&&!(h in u)&&(u[h]=u[d],delete u[d])},l=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(u){return typeof u=="object"&&typeof u.audio=="object"&&(u=JSON.parse(JSON.stringify(u)),o(u.audio,"autoGainControl","mozAutoGainControl"),o(u.audio,"noiseSuppression","mozNoiseSuppression")),l(u)},r&&r.prototype.getSettings){const u=r.prototype.getSettings;r.prototype.getSettings=function(){const d=u.apply(this,arguments);return o(d,"mozAutoGainControl","autoGainControl"),o(d,"mozNoiseSuppression","noiseSuppression"),d}}if(r&&r.prototype.applyConstraints){const u=r.prototype.applyConstraints;r.prototype.applyConstraints=function(d){return this.kind==="audio"&&typeof d=="object"&&(d=JSON.parse(JSON.stringify(d)),o(d,"autoGainControl","mozAutoGainControl"),o(d,"noiseSuppression","mozNoiseSuppression")),u.apply(this,[d])}}}}function gE(a,e){a.navigator.mediaDevices&&"getDisplayMedia"in a.navigator.mediaDevices||a.navigator.mediaDevices&&(a.navigator.mediaDevices.getDisplayMedia=function(r){if(!(r&&r.video)){const o=new DOMException("getDisplayMedia without video constraints is undefined");return o.name="NotFoundError",o.code=8,Promise.reject(o)}return r.video===!0?r.video={mediaSource:e}:r.video.mediaSource=e,a.navigator.mediaDevices.getUserMedia(r)})}function Sy(a){typeof a=="object"&&a.RTCTrackEvent&&"receiver"in a.RTCTrackEvent.prototype&&!("transceiver"in a.RTCTrackEvent.prototype)&&Object.defineProperty(a.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function tf(a,e){if(typeof a!="object"||!(a.RTCPeerConnection||a.mozRTCPeerConnection))return;!a.RTCPeerConnection&&a.mozRTCPeerConnection&&(a.RTCPeerConnection=a.mozRTCPeerConnection),e.version<53&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(o){const l=a.RTCPeerConnection.prototype[o],u={[o](){return arguments[0]=new(o==="addIceCandidate"?a.RTCIceCandidate:a.RTCSessionDescription)(arguments[0]),l.apply(this,arguments)}};a.RTCPeerConnection.prototype[o]=u[o]});const n={inboundrtp:"inbound-rtp",outboundrtp:"outbound-rtp",candidatepair:"candidate-pair",localcandidate:"local-candidate",remotecandidate:"remote-candidate"},r=a.RTCPeerConnection.prototype.getStats;a.RTCPeerConnection.prototype.getStats=function(){const[l,u,d]=arguments;return r.apply(this,[l||null]).then(h=>{if(e.version<53&&!u)try{h.forEach(m=>{m.type=n[m.type]||m.type})}catch(m){if(m.name!=="TypeError")throw m;h.forEach((g,y)=>{h.set(y,Object.assign({},g,{type:n[g.type]||g.type}))})}return h}).then(u,d)}}function Ty(a){if(!(typeof a=="object"&&a.RTCPeerConnection&&a.RTCRtpSender)||a.RTCRtpSender&&"getStats"in a.RTCRtpSender.prototype)return;const e=a.RTCPeerConnection.prototype.getSenders;e&&(a.RTCPeerConnection.prototype.getSenders=function(){const o=e.apply(this,[]);return o.forEach(l=>l._pc=this),o});const n=a.RTCPeerConnection.prototype.addTrack;n&&(a.RTCPeerConnection.prototype.addTrack=function(){const o=n.apply(this,arguments);return o._pc=this,o}),a.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function ky(a){if(!(typeof a=="object"&&a.RTCPeerConnection&&a.RTCRtpSender)||a.RTCRtpSender&&"getStats"in a.RTCRtpReceiver.prototype)return;const e=a.RTCPeerConnection.prototype.getReceivers;e&&(a.RTCPeerConnection.prototype.getReceivers=function(){const r=e.apply(this,[]);return r.forEach(o=>o._pc=this),r}),ba(a,"track",n=>(n.receiver._pc=n.srcElement,n)),a.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function Cy(a){!a.RTCPeerConnection||"removeStream"in a.RTCPeerConnection.prototype||(a.RTCPeerConnection.prototype.removeStream=function(n){qf("removeStream","removeTrack"),this.getSenders().forEach(r=>{r.track&&n.getTracks().includes(r.track)&&this.removeTrack(r)})})}function Ey(a){a.DataChannel&&!a.RTCDataChannel&&(a.RTCDataChannel=a.DataChannel)}function Ry(a){if(!(typeof a=="object"&&a.RTCPeerConnection))return;const e=a.RTCPeerConnection.prototype.addTransceiver;e&&(a.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let r=arguments[1]&&arguments[1].sendEncodings;r===void 0&&(r=[]),r=[...r];const o=r.length>0;o&&r.forEach(u=>{if("rid"in u&&!/^[a-z0-9]{0,16}$/i.test(u.rid))throw new TypeError("Invalid RID value provided.");if("scaleResolutionDownBy"in u&&!(parseFloat(u.scaleResolutionDownBy)>=1))throw new RangeError("scale_resolution_down_by must be >= 1.0");if("maxFramerate"in u&&!(parseFloat(u.maxFramerate)>=0))throw new RangeError("max_framerate must be >= 0.0")});const l=e.apply(this,arguments);if(o){const{sender:u}=l,d=u.getParameters();(!("encodings"in d)||d.encodings.length===1&&Object.keys(d.encodings[0]).length===0)&&(d.encodings=r,u.sendEncodings=r,this.setParametersPromises.push(u.setParameters(d).then(()=>{delete u.sendEncodings}).catch(()=>{delete u.sendEncodings})))}return l})}function _y(a){if(!(typeof a=="object"&&a.RTCRtpSender))return;const e=a.RTCRtpSender.prototype.getParameters;e&&(a.RTCRtpSender.prototype.getParameters=function(){const r=e.apply(this,arguments);return"encodings"in r||(r.encodings=[].concat(this.sendEncodings||[{}])),r})}function wy(a){if(!(typeof a=="object"&&a.RTCPeerConnection))return;const e=a.RTCPeerConnection.prototype.createOffer;a.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}function Oy(a){if(!(typeof a=="object"&&a.RTCPeerConnection))return;const e=a.RTCPeerConnection.prototype.createAnswer;a.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>e.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):e.apply(this,arguments)}}var Cv=Object.freeze({__proto__:null,shimAddTransceiver:Ry,shimCreateAnswer:Oy,shimCreateOffer:wy,shimGetDisplayMedia:gE,shimGetParameters:_y,shimGetUserMedia:by,shimOnTrack:Sy,shimPeerConnection:tf,shimRTCDataChannel:Ey,shimReceiverGetStats:ky,shimRemoveStream:Cy,shimSenderGetStats:Ty});function Dy(a){if(!(typeof a!="object"||!a.RTCPeerConnection)){if("getLocalStreams"in a.RTCPeerConnection.prototype||(a.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||(this._localStreams=[]),this._localStreams}),!("addStream"in a.RTCPeerConnection.prototype)){const e=a.RTCPeerConnection.prototype.addTrack;a.RTCPeerConnection.prototype.addStream=function(r){this._localStreams||(this._localStreams=[]),this._localStreams.includes(r)||this._localStreams.push(r),r.getAudioTracks().forEach(o=>e.call(this,o,r)),r.getVideoTracks().forEach(o=>e.call(this,o,r))},a.RTCPeerConnection.prototype.addTrack=function(r){for(var o=arguments.length,l=new Array(o>1?o-1:0),u=1;u<o;u++)l[u-1]=arguments[u];return l&&l.forEach(d=>{this._localStreams?this._localStreams.includes(d)||this._localStreams.push(d):this._localStreams=[d]}),e.apply(this,arguments)}}"removeStream"in a.RTCPeerConnection.prototype||(a.RTCPeerConnection.prototype.removeStream=function(n){this._localStreams||(this._localStreams=[]);const r=this._localStreams.indexOf(n);if(r===-1)return;this._localStreams.splice(r,1);const o=n.getTracks();this.getSenders().forEach(l=>{o.includes(l.track)&&this.removeTrack(l)})})}}function Ay(a){if(!(typeof a!="object"||!a.RTCPeerConnection)&&("getRemoteStreams"in a.RTCPeerConnection.prototype||(a.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!("onaddstream"in a.RTCPeerConnection.prototype))){Object.defineProperty(a.RTCPeerConnection.prototype,"onaddstream",{get(){return this._onaddstream},set(n){this._onaddstream&&(this.removeEventListener("addstream",this._onaddstream),this.removeEventListener("track",this._onaddstreampoly)),this.addEventListener("addstream",this._onaddstream=n),this.addEventListener("track",this._onaddstreampoly=r=>{r.streams.forEach(o=>{if(this._remoteStreams||(this._remoteStreams=[]),this._remoteStreams.includes(o))return;this._remoteStreams.push(o);const l=new Event("addstream");l.stream=o,this.dispatchEvent(l)})})}});const e=a.RTCPeerConnection.prototype.setRemoteDescription;a.RTCPeerConnection.prototype.setRemoteDescription=function(){const r=this;return this._onaddstreampoly||this.addEventListener("track",this._onaddstreampoly=function(o){o.streams.forEach(l=>{if(r._remoteStreams||(r._remoteStreams=[]),r._remoteStreams.indexOf(l)>=0)return;r._remoteStreams.push(l);const u=new Event("addstream");u.stream=l,r.dispatchEvent(u)})}),e.apply(r,arguments)}}}function My(a){if(typeof a!="object"||!a.RTCPeerConnection)return;const e=a.RTCPeerConnection.prototype,n=e.createOffer,r=e.createAnswer,o=e.setLocalDescription,l=e.setRemoteDescription,u=e.addIceCandidate;e.createOffer=function(m,g){const y=arguments.length>=2?arguments[2]:arguments[0],b=n.apply(this,[y]);return g?(b.then(m,g),Promise.resolve()):b},e.createAnswer=function(m,g){const y=arguments.length>=2?arguments[2]:arguments[0],b=r.apply(this,[y]);return g?(b.then(m,g),Promise.resolve()):b};let d=function(h,m,g){const y=o.apply(this,[h]);return g?(y.then(m,g),Promise.resolve()):y};e.setLocalDescription=d,d=function(h,m,g){const y=l.apply(this,[h]);return g?(y.then(m,g),Promise.resolve()):y},e.setRemoteDescription=d,d=function(h,m,g){const y=u.apply(this,[h]);return g?(y.then(m,g),Promise.resolve()):y},e.addIceCandidate=d}function Py(a){const e=a&&a.navigator;if(e.mediaDevices&&e.mediaDevices.getUserMedia){const n=e.mediaDevices,r=n.getUserMedia.bind(n);e.mediaDevices.getUserMedia=o=>r(xy(o))}!e.getUserMedia&&e.mediaDevices&&e.mediaDevices.getUserMedia&&(e.getUserMedia=(function(r,o,l){e.mediaDevices.getUserMedia(r).then(o,l)}).bind(e))}function xy(a){return a&&a.video!==void 0?Object.assign({},a,{video:uy(a.video)}):a}function Ny(a){if(!a.RTCPeerConnection)return;const e=a.RTCPeerConnection;a.RTCPeerConnection=function(r,o){if(r&&r.iceServers){const l=[];for(let u=0;u<r.iceServers.length;u++){let d=r.iceServers[u];d.urls===void 0&&d.url?(qf("RTCIceServer.url","RTCIceServer.urls"),d=JSON.parse(JSON.stringify(d)),d.urls=d.url,delete d.url,l.push(d)):l.push(r.iceServers[u])}r.iceServers=l}return new e(r,o)},a.RTCPeerConnection.prototype=e.prototype,"generateCertificate"in e&&Object.defineProperty(a.RTCPeerConnection,"generateCertificate",{get(){return e.generateCertificate}})}function Uy(a){typeof a=="object"&&a.RTCTrackEvent&&"receiver"in a.RTCTrackEvent.prototype&&!("transceiver"in a.RTCTrackEvent.prototype)&&Object.defineProperty(a.RTCTrackEvent.prototype,"transceiver",{get(){return{receiver:this.receiver}}})}function Ly(a){const e=a.RTCPeerConnection.prototype.createOffer;a.RTCPeerConnection.prototype.createOffer=function(r){if(r){typeof r.offerToReceiveAudio<"u"&&(r.offerToReceiveAudio=!!r.offerToReceiveAudio);const o=this.getTransceivers().find(u=>u.receiver.track.kind==="audio");r.offerToReceiveAudio===!1&&o?o.direction==="sendrecv"?o.setDirection?o.setDirection("sendonly"):o.direction="sendonly":o.direction==="recvonly"&&(o.setDirection?o.setDirection("inactive"):o.direction="inactive"):r.offerToReceiveAudio===!0&&!o&&this.addTransceiver("audio",{direction:"recvonly"}),typeof r.offerToReceiveVideo<"u"&&(r.offerToReceiveVideo=!!r.offerToReceiveVideo);const l=this.getTransceivers().find(u=>u.receiver.track.kind==="video");r.offerToReceiveVideo===!1&&l?l.direction==="sendrecv"?l.setDirection?l.setDirection("sendonly"):l.direction="sendonly":l.direction==="recvonly"&&(l.setDirection?l.setDirection("inactive"):l.direction="inactive"):r.offerToReceiveVideo===!0&&!l&&this.addTransceiver("video",{direction:"recvonly"})}return e.apply(this,arguments)}}function Iy(a){typeof a!="object"||a.AudioContext||(a.AudioContext=a.webkitAudioContext)}var Ev=Object.freeze({__proto__:null,shimAudioContext:Iy,shimCallbacksAPI:My,shimConstraints:xy,shimCreateOfferLegacy:Ly,shimGetUserMedia:Py,shimLocalStreamsAPI:Dy,shimRTCIceServerUrls:Ny,shimRemoteStreamsAPI:Ay,shimTrackEventTransceiver:Uy}),Ed={exports:{}},Rv;function vE(){return Rv||(Rv=1,function(a){const e={};e.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},e.localCName=e.generateIdentifier(),e.splitLines=function(n){return n.trim().split(`
`).map(r=>r.trim())},e.splitSections=function(n){return n.split(`
m=`).map((o,l)=>(l>0?"m="+o:o).trim()+`\r
`)},e.getDescription=function(n){const r=e.splitSections(n);return r&&r[0]},e.getMediaSections=function(n){const r=e.splitSections(n);return r.shift(),r},e.matchPrefix=function(n,r){return e.splitLines(n).filter(o=>o.indexOf(r)===0)},e.parseCandidate=function(n){let r;n.indexOf("a=candidate:")===0?r=n.substring(12).split(" "):r=n.substring(10).split(" ");const o={foundation:r[0],component:{1:"rtp",2:"rtcp"}[r[1]]||r[1],protocol:r[2].toLowerCase(),priority:parseInt(r[3],10),ip:r[4],address:r[4],port:parseInt(r[5],10),type:r[7]};for(let l=8;l<r.length;l+=2)switch(r[l]){case"raddr":o.relatedAddress=r[l+1];break;case"rport":o.relatedPort=parseInt(r[l+1],10);break;case"tcptype":o.tcpType=r[l+1];break;case"ufrag":o.ufrag=r[l+1],o.usernameFragment=r[l+1];break;default:o[r[l]]===void 0&&(o[r[l]]=r[l+1]);break}return o},e.writeCandidate=function(n){const r=[];r.push(n.foundation);const o=n.component;o==="rtp"?r.push(1):o==="rtcp"?r.push(2):r.push(o),r.push(n.protocol.toUpperCase()),r.push(n.priority),r.push(n.address||n.ip),r.push(n.port);const l=n.type;return r.push("typ"),r.push(l),l!=="host"&&n.relatedAddress&&n.relatedPort&&(r.push("raddr"),r.push(n.relatedAddress),r.push("rport"),r.push(n.relatedPort)),n.tcpType&&n.protocol.toLowerCase()==="tcp"&&(r.push("tcptype"),r.push(n.tcpType)),(n.usernameFragment||n.ufrag)&&(r.push("ufrag"),r.push(n.usernameFragment||n.ufrag)),"candidate:"+r.join(" ")},e.parseIceOptions=function(n){return n.substring(14).split(" ")},e.parseRtpMap=function(n){let r=n.substring(9).split(" ");const o={payloadType:parseInt(r.shift(),10)};return r=r[0].split("/"),o.name=r[0],o.clockRate=parseInt(r[1],10),o.channels=r.length===3?parseInt(r[2],10):1,o.numChannels=o.channels,o},e.writeRtpMap=function(n){let r=n.payloadType;n.preferredPayloadType!==void 0&&(r=n.preferredPayloadType);const o=n.channels||n.numChannels||1;return"a=rtpmap:"+r+" "+n.name+"/"+n.clockRate+(o!==1?"/"+o:"")+`\r
`},e.parseExtmap=function(n){const r=n.substring(9).split(" ");return{id:parseInt(r[0],10),direction:r[0].indexOf("/")>0?r[0].split("/")[1]:"sendrecv",uri:r[1],attributes:r.slice(2).join(" ")}},e.writeExtmap=function(n){return"a=extmap:"+(n.id||n.preferredId)+(n.direction&&n.direction!=="sendrecv"?"/"+n.direction:"")+" "+n.uri+(n.attributes?" "+n.attributes:"")+`\r
`},e.parseFmtp=function(n){const r={};let o;const l=n.substring(n.indexOf(" ")+1).split(";");for(let u=0;u<l.length;u++)o=l[u].trim().split("="),r[o[0].trim()]=o[1];return r},e.writeFmtp=function(n){let r="",o=n.payloadType;if(n.preferredPayloadType!==void 0&&(o=n.preferredPayloadType),n.parameters&&Object.keys(n.parameters).length){const l=[];Object.keys(n.parameters).forEach(u=>{n.parameters[u]!==void 0?l.push(u+"="+n.parameters[u]):l.push(u)}),r+="a=fmtp:"+o+" "+l.join(";")+`\r
`}return r},e.parseRtcpFb=function(n){const r=n.substring(n.indexOf(" ")+1).split(" ");return{type:r.shift(),parameter:r.join(" ")}},e.writeRtcpFb=function(n){let r="",o=n.payloadType;return n.preferredPayloadType!==void 0&&(o=n.preferredPayloadType),n.rtcpFeedback&&n.rtcpFeedback.length&&n.rtcpFeedback.forEach(l=>{r+="a=rtcp-fb:"+o+" "+l.type+(l.parameter&&l.parameter.length?" "+l.parameter:"")+`\r
`}),r},e.parseSsrcMedia=function(n){const r=n.indexOf(" "),o={ssrc:parseInt(n.substring(7,r),10)},l=n.indexOf(":",r);return l>-1?(o.attribute=n.substring(r+1,l),o.value=n.substring(l+1)):o.attribute=n.substring(r+1),o},e.parseSsrcGroup=function(n){const r=n.substring(13).split(" ");return{semantics:r.shift(),ssrcs:r.map(o=>parseInt(o,10))}},e.getMid=function(n){const r=e.matchPrefix(n,"a=mid:")[0];if(r)return r.substring(6)},e.parseFingerprint=function(n){const r=n.substring(14).split(" ");return{algorithm:r[0].toLowerCase(),value:r[1].toUpperCase()}},e.getDtlsParameters=function(n,r){return{role:"auto",fingerprints:e.matchPrefix(n+r,"a=fingerprint:").map(e.parseFingerprint)}},e.writeDtlsParameters=function(n,r){let o="a=setup:"+r+`\r
`;return n.fingerprints.forEach(l=>{o+="a=fingerprint:"+l.algorithm+" "+l.value+`\r
`}),o},e.parseCryptoLine=function(n){const r=n.substring(9).split(" ");return{tag:parseInt(r[0],10),cryptoSuite:r[1],keyParams:r[2],sessionParams:r.slice(3)}},e.writeCryptoLine=function(n){return"a=crypto:"+n.tag+" "+n.cryptoSuite+" "+(typeof n.keyParams=="object"?e.writeCryptoKeyParams(n.keyParams):n.keyParams)+(n.sessionParams?" "+n.sessionParams.join(" "):"")+`\r
`},e.parseCryptoKeyParams=function(n){if(n.indexOf("inline:")!==0)return null;const r=n.substring(7).split("|");return{keyMethod:"inline",keySalt:r[0],lifeTime:r[1],mkiValue:r[2]?r[2].split(":")[0]:void 0,mkiLength:r[2]?r[2].split(":")[1]:void 0}},e.writeCryptoKeyParams=function(n){return n.keyMethod+":"+n.keySalt+(n.lifeTime?"|"+n.lifeTime:"")+(n.mkiValue&&n.mkiLength?"|"+n.mkiValue+":"+n.mkiLength:"")},e.getCryptoParameters=function(n,r){return e.matchPrefix(n+r,"a=crypto:").map(e.parseCryptoLine)},e.getIceParameters=function(n,r){const o=e.matchPrefix(n+r,"a=ice-ufrag:")[0],l=e.matchPrefix(n+r,"a=ice-pwd:")[0];return o&&l?{usernameFragment:o.substring(12),password:l.substring(10)}:null},e.writeIceParameters=function(n){let r="a=ice-ufrag:"+n.usernameFragment+`\r
a=ice-pwd:`+n.password+`\r
`;return n.iceLite&&(r+=`a=ice-lite\r
`),r},e.parseRtpParameters=function(n){const r={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},l=e.splitLines(n)[0].split(" ");r.profile=l[2];for(let d=3;d<l.length;d++){const h=l[d],m=e.matchPrefix(n,"a=rtpmap:"+h+" ")[0];if(m){const g=e.parseRtpMap(m),y=e.matchPrefix(n,"a=fmtp:"+h+" ");switch(g.parameters=y.length?e.parseFmtp(y[0]):{},g.rtcpFeedback=e.matchPrefix(n,"a=rtcp-fb:"+h+" ").map(e.parseRtcpFb),r.codecs.push(g),g.name.toUpperCase()){case"RED":case"ULPFEC":r.fecMechanisms.push(g.name.toUpperCase());break}}}e.matchPrefix(n,"a=extmap:").forEach(d=>{r.headerExtensions.push(e.parseExtmap(d))});const u=e.matchPrefix(n,"a=rtcp-fb:* ").map(e.parseRtcpFb);return r.codecs.forEach(d=>{u.forEach(h=>{d.rtcpFeedback.find(g=>g.type===h.type&&g.parameter===h.parameter)||d.rtcpFeedback.push(h)})}),r},e.writeRtpDescription=function(n,r){let o="";o+="m="+n+" ",o+=r.codecs.length>0?"9":"0",o+=" "+(r.profile||"UDP/TLS/RTP/SAVPF")+" ",o+=r.codecs.map(u=>u.preferredPayloadType!==void 0?u.preferredPayloadType:u.payloadType).join(" ")+`\r
`,o+=`c=IN IP4 0.0.0.0\r
`,o+=`a=rtcp:9 IN IP4 0.0.0.0\r
`,r.codecs.forEach(u=>{o+=e.writeRtpMap(u),o+=e.writeFmtp(u),o+=e.writeRtcpFb(u)});let l=0;return r.codecs.forEach(u=>{u.maxptime>l&&(l=u.maxptime)}),l>0&&(o+="a=maxptime:"+l+`\r
`),r.headerExtensions&&r.headerExtensions.forEach(u=>{o+=e.writeExtmap(u)}),o},e.parseRtpEncodingParameters=function(n){const r=[],o=e.parseRtpParameters(n),l=o.fecMechanisms.indexOf("RED")!==-1,u=o.fecMechanisms.indexOf("ULPFEC")!==-1,d=e.matchPrefix(n,"a=ssrc:").map(b=>e.parseSsrcMedia(b)).filter(b=>b.attribute==="cname"),h=d.length>0&&d[0].ssrc;let m;const g=e.matchPrefix(n,"a=ssrc-group:FID").map(b=>b.substring(17).split(" ").map(C=>parseInt(C,10)));g.length>0&&g[0].length>1&&g[0][0]===h&&(m=g[0][1]),o.codecs.forEach(b=>{if(b.name.toUpperCase()==="RTX"&&b.parameters.apt){let T={ssrc:h,codecPayloadType:parseInt(b.parameters.apt,10)};h&&m&&(T.rtx={ssrc:m}),r.push(T),l&&(T=JSON.parse(JSON.stringify(T)),T.fec={ssrc:h,mechanism:u?"red+ulpfec":"red"},r.push(T))}}),r.length===0&&h&&r.push({ssrc:h});let y=e.matchPrefix(n,"b=");return y.length&&(y[0].indexOf("b=TIAS:")===0?y=parseInt(y[0].substring(7),10):y[0].indexOf("b=AS:")===0?y=parseInt(y[0].substring(5),10)*1e3*.95-50*40*8:y=void 0,r.forEach(b=>{b.maxBitrate=y})),r},e.parseRtcpParameters=function(n){const r={},o=e.matchPrefix(n,"a=ssrc:").map(d=>e.parseSsrcMedia(d)).filter(d=>d.attribute==="cname")[0];o&&(r.cname=o.value,r.ssrc=o.ssrc);const l=e.matchPrefix(n,"a=rtcp-rsize");r.reducedSize=l.length>0,r.compound=l.length===0;const u=e.matchPrefix(n,"a=rtcp-mux");return r.mux=u.length>0,r},e.writeRtcpParameters=function(n){let r="";return n.reducedSize&&(r+=`a=rtcp-rsize\r
`),n.mux&&(r+=`a=rtcp-mux\r
`),n.ssrc!==void 0&&n.cname&&(r+="a=ssrc:"+n.ssrc+" cname:"+n.cname+`\r
`),r},e.parseMsid=function(n){let r;const o=e.matchPrefix(n,"a=msid:");if(o.length===1)return r=o[0].substring(7).split(" "),{stream:r[0],track:r[1]};const l=e.matchPrefix(n,"a=ssrc:").map(u=>e.parseSsrcMedia(u)).filter(u=>u.attribute==="msid");if(l.length>0)return r=l[0].value.split(" "),{stream:r[0],track:r[1]}},e.parseSctpDescription=function(n){const r=e.parseMLine(n),o=e.matchPrefix(n,"a=max-message-size:");let l;o.length>0&&(l=parseInt(o[0].substring(19),10)),isNaN(l)&&(l=65536);const u=e.matchPrefix(n,"a=sctp-port:");if(u.length>0)return{port:parseInt(u[0].substring(12),10),protocol:r.fmt,maxMessageSize:l};const d=e.matchPrefix(n,"a=sctpmap:");if(d.length>0){const h=d[0].substring(10).split(" ");return{port:parseInt(h[0],10),protocol:h[1],maxMessageSize:l}}},e.writeSctpDescription=function(n,r){let o=[];return n.protocol!=="DTLS/SCTP"?o=["m="+n.kind+" 9 "+n.protocol+" "+r.protocol+`\r
`,`c=IN IP4 0.0.0.0\r
`,"a=sctp-port:"+r.port+`\r
`]:o=["m="+n.kind+" 9 "+n.protocol+" "+r.port+`\r
`,`c=IN IP4 0.0.0.0\r
`,"a=sctpmap:"+r.port+" "+r.protocol+` 65535\r
`],r.maxMessageSize!==void 0&&o.push("a=max-message-size:"+r.maxMessageSize+`\r
`),o.join("")},e.generateSessionId=function(){return Math.random().toString().substr(2,22)},e.writeSessionBoilerplate=function(n,r,o){let l;const u=r!==void 0?r:2;return n?l=n:l=e.generateSessionId(),`v=0\r
o=`+(o||"thisisadapterortc")+" "+l+" "+u+` IN IP4 127.0.0.1\r
s=-\r
t=0 0\r
`},e.getDirection=function(n,r){const o=e.splitLines(n);for(let l=0;l<o.length;l++)switch(o[l]){case"a=sendrecv":case"a=sendonly":case"a=recvonly":case"a=inactive":return o[l].substring(2)}return r?e.getDirection(r):"sendrecv"},e.getKind=function(n){return e.splitLines(n)[0].split(" ")[0].substring(2)},e.isRejected=function(n){return n.split(" ",2)[1]==="0"},e.parseMLine=function(n){const o=e.splitLines(n)[0].substring(2).split(" ");return{kind:o[0],port:parseInt(o[1],10),protocol:o[2],fmt:o.slice(3).join(" ")}},e.parseOLine=function(n){const o=e.matchPrefix(n,"o=")[0].substring(2).split(" ");return{username:o[0],sessionId:o[1],sessionVersion:parseInt(o[2],10),netType:o[3],addressType:o[4],address:o[5]}},e.isValidSDP=function(n){if(typeof n!="string"||n.length===0)return!1;const r=e.splitLines(n);for(let o=0;o<r.length;o++)if(r[o].length<2||r[o].charAt(1)!=="=")return!1;return!0},a.exports=e}(Ed)),Ed.exports}var jy=vE(),dr=rE(jy),yE=Pk({__proto__:null,default:dr},[jy]);function kc(a){if(!a.RTCIceCandidate||a.RTCIceCandidate&&"foundation"in a.RTCIceCandidate.prototype)return;const e=a.RTCIceCandidate;a.RTCIceCandidate=function(r){if(typeof r=="object"&&r.candidate&&r.candidate.indexOf("a=")===0&&(r=JSON.parse(JSON.stringify(r)),r.candidate=r.candidate.substring(2)),r.candidate&&r.candidate.length){const o=new e(r),l=dr.parseCandidate(r.candidate);for(const u in l)u in o||Object.defineProperty(o,u,{value:l[u]});return o.toJSON=function(){return{candidate:o.candidate,sdpMid:o.sdpMid,sdpMLineIndex:o.sdpMLineIndex,usernameFragment:o.usernameFragment}},o}return new e(r)},a.RTCIceCandidate.prototype=e.prototype,ba(a,"icecandidate",n=>(n.candidate&&Object.defineProperty(n,"candidate",{value:new a.RTCIceCandidate(n.candidate),writable:"false"}),n))}function nf(a){!a.RTCIceCandidate||a.RTCIceCandidate&&"relayProtocol"in a.RTCIceCandidate.prototype||ba(a,"icecandidate",e=>{if(e.candidate){const n=dr.parseCandidate(e.candidate.candidate);n.type==="relay"&&(e.candidate.relayProtocol={0:"tls",1:"tcp",2:"udp"}[n.priority>>24])}return e})}function Cc(a,e){if(!a.RTCPeerConnection)return;"sctp"in a.RTCPeerConnection.prototype||Object.defineProperty(a.RTCPeerConnection.prototype,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp}});const n=function(d){if(!d||!d.sdp)return!1;const h=dr.splitSections(d.sdp);return h.shift(),h.some(m=>{const g=dr.parseMLine(m);return g&&g.kind==="application"&&g.protocol.indexOf("SCTP")!==-1})},r=function(d){const h=d.sdp.match(/mozilla...THIS_IS_SDPARTA-(\d+)/);if(h===null||h.length<2)return-1;const m=parseInt(h[1],10);return m!==m?-1:m},o=function(d){let h=65536;return e.browser==="firefox"&&(e.version<57?d===-1?h=16384:h=2147483637:e.version<60?h=e.version===57?65535:65536:h=2147483637),h},l=function(d,h){let m=65536;e.browser==="firefox"&&e.version===57&&(m=65535);const g=dr.matchPrefix(d.sdp,"a=max-message-size:");return g.length>0?m=parseInt(g[0].substring(19),10):e.browser==="firefox"&&h!==-1&&(m=2147483637),m},u=a.RTCPeerConnection.prototype.setRemoteDescription;a.RTCPeerConnection.prototype.setRemoteDescription=function(){if(this._sctp=null,e.browser==="chrome"&&e.version>=76){const{sdpSemantics:h}=this.getConfiguration();h==="plan-b"&&Object.defineProperty(this,"sctp",{get(){return typeof this._sctp>"u"?null:this._sctp},enumerable:!0,configurable:!0})}if(n(arguments[0])){const h=r(arguments[0]),m=o(h),g=l(arguments[0],h);let y;m===0&&g===0?y=Number.POSITIVE_INFINITY:m===0||g===0?y=Math.max(m,g):y=Math.min(m,g);const b={};Object.defineProperty(b,"maxMessageSize",{get(){return y}}),this._sctp=b}return u.apply(this,arguments)}}function Ec(a){if(!(a.RTCPeerConnection&&"createDataChannel"in a.RTCPeerConnection.prototype))return;function e(r,o){const l=r.send;r.send=function(){const d=arguments[0],h=d.length||d.size||d.byteLength;if(r.readyState==="open"&&o.sctp&&h>o.sctp.maxMessageSize)throw new TypeError("Message too large (can send a maximum of "+o.sctp.maxMessageSize+" bytes)");return l.apply(r,arguments)}}const n=a.RTCPeerConnection.prototype.createDataChannel;a.RTCPeerConnection.prototype.createDataChannel=function(){const o=n.apply(this,arguments);return e(o,this),o},ba(a,"datachannel",r=>(e(r.channel,r.target),r))}function af(a){if(!a.RTCPeerConnection||"connectionState"in a.RTCPeerConnection.prototype)return;const e=a.RTCPeerConnection.prototype;Object.defineProperty(e,"connectionState",{get(){return{completed:"connected",checking:"connecting"}[this.iceConnectionState]||this.iceConnectionState},enumerable:!0,configurable:!0}),Object.defineProperty(e,"onconnectionstatechange",{get(){return this._onconnectionstatechange||null},set(n){this._onconnectionstatechange&&(this.removeEventListener("connectionstatechange",this._onconnectionstatechange),delete this._onconnectionstatechange),n&&this.addEventListener("connectionstatechange",this._onconnectionstatechange=n)},enumerable:!0,configurable:!0}),["setLocalDescription","setRemoteDescription"].forEach(n=>{const r=e[n];e[n]=function(){return this._connectionstatechangepoly||(this._connectionstatechangepoly=o=>{const l=o.target;if(l._lastConnectionState!==l.connectionState){l._lastConnectionState=l.connectionState;const u=new Event("connectionstatechange",o);l.dispatchEvent(u)}return o},this.addEventListener("iceconnectionstatechange",this._connectionstatechangepoly)),r.apply(this,arguments)}})}function rf(a,e){if(!a.RTCPeerConnection||e.browser==="chrome"&&e.version>=71||e.browser==="safari"&&e.version>=605)return;const n=a.RTCPeerConnection.prototype.setRemoteDescription;a.RTCPeerConnection.prototype.setRemoteDescription=function(o){if(o&&o.sdp&&o.sdp.indexOf(`
a=extmap-allow-mixed`)!==-1){const l=o.sdp.split(`
`).filter(u=>u.trim()!=="a=extmap-allow-mixed").join(`
`);a.RTCSessionDescription&&o instanceof a.RTCSessionDescription?arguments[0]=new a.RTCSessionDescription({type:o.type,sdp:l}):o.sdp=l}return n.apply(this,arguments)}}function Rc(a,e){if(!(a.RTCPeerConnection&&a.RTCPeerConnection.prototype))return;const n=a.RTCPeerConnection.prototype.addIceCandidate;!n||n.length===0||(a.RTCPeerConnection.prototype.addIceCandidate=function(){return arguments[0]?(e.browser==="chrome"&&e.version<78||e.browser==="firefox"&&e.version<68||e.browser==="safari")&&arguments[0]&&arguments[0].candidate===""?Promise.resolve():n.apply(this,arguments):(arguments[1]&&arguments[1].apply(null),Promise.resolve())})}function _c(a,e){if(!(a.RTCPeerConnection&&a.RTCPeerConnection.prototype))return;const n=a.RTCPeerConnection.prototype.setLocalDescription;!n||n.length===0||(a.RTCPeerConnection.prototype.setLocalDescription=function(){let o=arguments[0]||{};if(typeof o!="object"||o.type&&o.sdp)return n.apply(this,arguments);if(o={type:o.type,sdp:o.sdp},!o.type)switch(this.signalingState){case"stable":case"have-local-offer":case"have-remote-pranswer":o.type="offer";break;default:o.type="answer";break}return o.sdp||o.type!=="offer"&&o.type!=="answer"?n.apply(this,[o]):(o.type==="offer"?this.createOffer:this.createAnswer).apply(this).then(u=>n.apply(this,[u]))})}var bE=Object.freeze({__proto__:null,removeExtmapAllowMixed:rf,shimAddIceCandidateNullOrEmpty:Rc,shimConnectionState:af,shimMaxMessageSize:Cc,shimParameterlessSetLocalDescription:_c,shimRTCIceCandidate:kc,shimRTCIceCandidateRelayProtocol:nf,shimSendThrowTypeError:Ec});function SE(){let{window:a}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shimChrome:!0,shimFirefox:!0,shimSafari:!0};const n=ly,r=pE(a),o={browserDetails:r,commonShim:bE,extractVersion:Tc,disableLog:hE,disableWarnings:mE,sdp:yE};switch(r.browser){case"chrome":if(!kv||!ef||!e.shimChrome)return n("Chrome shim is not included in this adapter release."),o;if(r.version===null)return n("Chrome shim can not determine version, not shimming."),o;n("adapter.js shimming chrome."),o.browserShim=kv,Rc(a,r),_c(a),dy(a,r),fy(a),ef(a,r),hy(a),vy(a,r),my(a),py(a),yy(a,r),kc(a),nf(a),af(a),Cc(a,r),Ec(a),rf(a,r);break;case"firefox":if(!Cv||!tf||!e.shimFirefox)return n("Firefox shim is not included in this adapter release."),o;n("adapter.js shimming firefox."),o.browserShim=Cv,Rc(a,r),_c(a),by(a,r),tf(a,r),Sy(a),Cy(a),Ty(a),ky(a),Ey(a),Ry(a),_y(a),wy(a),Oy(a),kc(a),af(a),Cc(a,r),Ec(a);break;case"safari":if(!Ev||!e.shimSafari)return n("Safari shim is not included in this adapter release."),o;n("adapter.js shimming safari."),o.browserShim=Ev,Rc(a,r),_c(a),Ny(a),Ly(a),My(a),Dy(a),Ay(a),Uy(a),Py(a),Iy(a),kc(a),nf(a),Cc(a,r),Ec(a),rf(a,r);break;default:n("Unsupported browser!");break}return o}SE({window:typeof window>"u"?void 0:window});const TE=10,fc="lk_e2ee",kE="LKFrameEncryptionKey",CE={sharedKey:!1,ratchetSalt:kE,ratchetWindowSize:8,failureTolerance:TE,keyringSize:16};var Li;(function(a){a.SetKey="setKey",a.RatchetRequest="ratchetRequest",a.KeyRatcheted="keyRatcheted"})(Li||(Li={}));var _v;(function(a){a.KeyRatcheted="keyRatcheted"})(_v||(_v={}));var Ui;(function(a){a.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",a.EncryptionError="encryptionError"})(Ui||(Ui={}));var wv;(function(a){a.Error="cryptorError"})(wv||(wv={}));function EE(){return RE()||sf()}function sf(){return typeof window.RTCRtpScriptTransform<"u"}function RE(){return typeof window.RTCRtpSender<"u"&&typeof window.RTCRtpSender.prototype.createEncodedStreams<"u"}class yO extends xn.EventEmitter{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(),this.onKeyRatcheted=(n,r)=>{ke.debug("key ratcheted event received",{material:n,keyIndex:r})},this.keyInfoMap=new Map,this.options=Object.assign(Object.assign({},CE),e),this.on(Li.KeyRatcheted,this.onKeyRatcheted)}onSetEncryptionKey(e,n,r){const o={key:e,participantIdentity:n,keyIndex:r};if(!this.options.sharedKey&&!n)throw new Error("participant identity needs to be passed for encryption key if sharedKey option is false");this.keyInfoMap.set("".concat(n??"shared","-").concat(r??0),o),this.emit(Li.SetKey,o)}getKeys(){return Array.from(this.keyInfoMap.values())}getOptions(){return this.options}ratchetKey(e,n){this.emit(Li.RatchetRequest,e,n)}}class Vi extends Error{constructor(e,n){super(n||"an error has occured"),this.name="LiveKitError",this.code=e}}var Re;(function(a){a[a.NotAllowed=0]="NotAllowed",a[a.ServerUnreachable=1]="ServerUnreachable",a[a.InternalError=2]="InternalError",a[a.Cancelled=3]="Cancelled",a[a.LeaveRequest=4]="LeaveRequest"})(Re||(Re={}));class Ie extends Vi{constructor(e,n,r,o){super(1,e),this.name="ConnectionError",this.status=r,this.reason=n,this.context=o,this.reasonName=Re[n]}}class Vf extends Vi{constructor(e){super(21,e??"device is unsupported"),this.name="DeviceUnsupportedError"}}class $n extends Vi{constructor(e){super(20,e??"track is invalid"),this.name="TrackInvalidError"}}class _E extends Vi{constructor(e){super(10,e??"unsupported server"),this.name="UnsupportedServer"}}class ut extends Vi{constructor(e){super(12,e??"unexpected connection state"),this.name="UnexpectedConnectionState"}}class of extends Vi{constructor(e){super(13,e??"unable to negotiate"),this.name="NegotiationError"}}class wE extends Vi{constructor(e,n){super(15,e),this.name="PublishTrackError",this.status=n}}class Ov extends Vi{constructor(e,n){super(15,e),this.reason=n,this.reasonName=typeof n=="string"?n:zf[n]}}var Vs;(function(a){a.PermissionDenied="PermissionDenied",a.NotFound="NotFound",a.DeviceInUse="DeviceInUse",a.Other="Other"})(Vs||(Vs={}));(function(a){function e(n){if(n&&"name"in n)return n.name==="NotFoundError"||n.name==="DevicesNotFoundError"?a.NotFound:n.name==="NotAllowedError"||n.name==="PermissionDeniedError"?a.PermissionDenied:n.name==="NotReadableError"||n.name==="TrackStartError"?a.DeviceInUse:a.Other}a.getFailure=e})(Vs||(Vs={}));var Dv;(function(a){a[a.InvalidKey=0]="InvalidKey",a[a.MissingKey=1]="MissingKey",a[a.InternalError=2]="InternalError"})(Dv||(Dv={}));var B;(function(a){a.Connected="connected",a.Reconnecting="reconnecting",a.SignalReconnecting="signalReconnecting",a.Reconnected="reconnected",a.Disconnected="disconnected",a.ConnectionStateChanged="connectionStateChanged",a.MediaDevicesChanged="mediaDevicesChanged",a.ParticipantConnected="participantConnected",a.ParticipantDisconnected="participantDisconnected",a.TrackPublished="trackPublished",a.TrackSubscribed="trackSubscribed",a.TrackSubscriptionFailed="trackSubscriptionFailed",a.TrackUnpublished="trackUnpublished",a.TrackUnsubscribed="trackUnsubscribed",a.TrackMuted="trackMuted",a.TrackUnmuted="trackUnmuted",a.LocalTrackPublished="localTrackPublished",a.LocalTrackUnpublished="localTrackUnpublished",a.LocalAudioSilenceDetected="localAudioSilenceDetected",a.ActiveSpeakersChanged="activeSpeakersChanged",a.ParticipantMetadataChanged="participantMetadataChanged",a.ParticipantNameChanged="participantNameChanged",a.ParticipantAttributesChanged="participantAttributesChanged",a.RoomMetadataChanged="roomMetadataChanged",a.DataReceived="dataReceived",a.SipDTMFReceived="sipDTMFReceived",a.TranscriptionReceived="transcriptionReceived",a.ConnectionQualityChanged="connectionQualityChanged",a.TrackStreamStateChanged="trackStreamStateChanged",a.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",a.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",a.AudioPlaybackStatusChanged="audioPlaybackChanged",a.VideoPlaybackStatusChanged="videoPlaybackChanged",a.MediaDevicesError="mediaDevicesError",a.ParticipantPermissionsChanged="participantPermissionsChanged",a.SignalConnected="signalConnected",a.RecordingStatusChanged="recordingStatusChanged",a.ParticipantEncryptionStatusChanged="participantEncryptionStatusChanged",a.EncryptionError="encryptionError",a.DCBufferStatusChanged="dcBufferStatusChanged",a.ActiveDeviceChanged="activeDeviceChanged",a.ChatMessage="chatMessage",a.LocalTrackSubscribed="localTrackSubscribed",a.MetricsReceived="metricsReceived"})(B||(B={}));var F;(function(a){a.TrackPublished="trackPublished",a.TrackSubscribed="trackSubscribed",a.TrackSubscriptionFailed="trackSubscriptionFailed",a.TrackUnpublished="trackUnpublished",a.TrackUnsubscribed="trackUnsubscribed",a.TrackMuted="trackMuted",a.TrackUnmuted="trackUnmuted",a.LocalTrackPublished="localTrackPublished",a.LocalTrackUnpublished="localTrackUnpublished",a.ParticipantMetadataChanged="participantMetadataChanged",a.ParticipantNameChanged="participantNameChanged",a.DataReceived="dataReceived",a.SipDTMFReceived="sipDTMFReceived",a.TranscriptionReceived="transcriptionReceived",a.IsSpeakingChanged="isSpeakingChanged",a.ConnectionQualityChanged="connectionQualityChanged",a.TrackStreamStateChanged="trackStreamStateChanged",a.TrackSubscriptionPermissionChanged="trackSubscriptionPermissionChanged",a.TrackSubscriptionStatusChanged="trackSubscriptionStatusChanged",a.MediaDevicesError="mediaDevicesError",a.AudioStreamAcquired="audioStreamAcquired",a.ParticipantPermissionsChanged="participantPermissionsChanged",a.PCTrackAdded="pcTrackAdded",a.AttributesChanged="attributesChanged",a.LocalTrackSubscribed="localTrackSubscribed",a.ChatMessage="chatMessage"})(F||(F={}));var ne;(function(a){a.TransportsCreated="transportsCreated",a.Connected="connected",a.Disconnected="disconnected",a.Resuming="resuming",a.Resumed="resumed",a.Restarting="restarting",a.Restarted="restarted",a.SignalResumed="signalResumed",a.SignalRestarted="signalRestarted",a.Closing="closing",a.MediaTrackAdded="mediaTrackAdded",a.ActiveSpeakersUpdate="activeSpeakersUpdate",a.DataPacketReceived="dataPacketReceived",a.RTPVideoMapUpdate="rtpVideoMapUpdate",a.DCBufferStatusChanged="dcBufferStatusChanged",a.ParticipantUpdate="participantUpdate",a.RoomUpdate="roomUpdate",a.SpeakersChanged="speakersChanged",a.StreamStateChanged="streamStateChanged",a.ConnectionQualityUpdate="connectionQualityUpdate",a.SubscriptionError="subscriptionError",a.SubscriptionPermissionUpdate="subscriptionPermissionUpdate",a.RemoteMute="remoteMute",a.SubscribedQualityUpdate="subscribedQualityUpdate",a.LocalTrackUnpublished="localTrackUnpublished",a.LocalTrackSubscribed="localTrackSubscribed",a.Offline="offline",a.SignalRequestResponse="signalRequestResponse"})(ne||(ne={}));var W;(function(a){a.Message="message",a.Muted="muted",a.Unmuted="unmuted",a.Restarted="restarted",a.Ended="ended",a.Subscribed="subscribed",a.Unsubscribed="unsubscribed",a.UpdateSettings="updateSettings",a.UpdateSubscription="updateSubscription",a.AudioPlaybackStarted="audioPlaybackStarted",a.AudioPlaybackFailed="audioPlaybackFailed",a.AudioSilenceDetected="audioSilenceDetected",a.VisibilityChanged="visibilityChanged",a.VideoDimensionsChanged="videoDimensionsChanged",a.VideoPlaybackStarted="videoPlaybackStarted",a.VideoPlaybackFailed="videoPlaybackFailed",a.ElementAttached="elementAttached",a.ElementDetached="elementDetached",a.UpstreamPaused="upstreamPaused",a.UpstreamResumed="upstreamResumed",a.SubscriptionPermissionChanged="subscriptionPermissionChanged",a.SubscriptionStatusChanged="subscriptionStatusChanged",a.SubscriptionFailed="subscriptionFailed",a.TrackProcessorUpdate="trackProcessorUpdate",a.AudioTrackFeatureUpdate="audioTrackFeatureUpdate",a.TranscriptionReceived="transcriptionReceived",a.TimeSyncUpdate="timeSyncUpdate"})(W||(W={}));function OE(a){if(!(typeof a>"u"))return typeof structuredClone=="function"?structuredClone(a):JSON.parse(JSON.stringify(a))}const DE=/version\/(\d+(\.?_?\d+)+)/i;let Rd;function Dn(a){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(typeof navigator>"u")return;const n=navigator.userAgent.toLowerCase();if(Rd===void 0||e){const r=AE.find(o=>{let{test:l}=o;return l.test(n)});Rd=r==null?void 0:r.describe(n)}return Rd}const AE=[{test:/firefox|iceweasel|fxios/i,describe(a){return{name:"Firefox",version:wc(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,a),os:a.toLowerCase().includes("fxios")?"iOS":void 0,osVersion:_d(a)}}},{test:/chrom|crios|crmo/i,describe(a){return{name:"Chrome",version:wc(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i,a),os:a.toLowerCase().includes("crios")?"iOS":void 0,osVersion:_d(a)}}},{test:/safari|applewebkit/i,describe(a){return{name:"Safari",version:wc(DE,a),os:a.includes("mobile/")?"iOS":"macOS",osVersion:_d(a)}}}];function wc(a,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;const r=e.match(a);return r&&r.length>=n&&r[n]||""}function _d(a){return a.includes("mac os")?wc(/\(.+?(\d+_\d+(:?_\d+)?)/,a,1).replace(/_/g,"."):void 0}var ME="2.9.8";const PE=ME,xE=15;class Tt{}Tt.setTimeout=function(){return setTimeout(...arguments)};Tt.setInterval=function(){return setInterval(...arguments)};Tt.clearTimeout=function(){return clearTimeout(...arguments)};Tt.clearInterval=function(){return clearInterval(...arguments)};const NE=5e3,Ds=[];var rn;(function(a){a[a.LOW=0]="LOW",a[a.MEDIUM=1]="MEDIUM",a[a.HIGH=2]="HIGH"})(rn||(rn={}));class j extends xn.EventEmitter{constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};var o;super(),this.attachedElements=[],this.isMuted=!1,this.streamState=j.StreamState.Active,this.isInBackground=!1,this._currentBitrate=0,this.log=ke,this.appVisibilityChangedListener=()=>{this.backgroundTimeout&&clearTimeout(this.backgroundTimeout),document.visibilityState==="hidden"?this.backgroundTimeout=setTimeout(()=>this.handleAppVisibilityChanged(),NE):this.handleAppVisibilityChanged()},this.log=ei((o=r.loggerName)!==null&&o!==void 0?o:gn.Track),this.loggerContextCb=r.loggerContextCb,this.setMaxListeners(100),this.kind=n,this._mediaStreamTrack=e,this._mediaStreamID=e.id,this.source=j.Source.Unknown}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),Me(this))}get currentBitrate(){return this._currentBitrate}get mediaStreamTrack(){return this._mediaStreamTrack}get mediaStreamID(){return this._mediaStreamID}attach(e){let n="audio";this.kind===j.Kind.Video&&(n="video"),this.attachedElements.length===0&&this.kind===j.Kind.Video&&this.addAppVisibilityListener(),e||(n==="audio"&&(Ds.forEach(l=>{l.parentElement===null&&!e&&(e=l)}),e&&Ds.splice(Ds.indexOf(e),1)),e||(e=document.createElement(n))),this.attachedElements.includes(e)||this.attachedElements.push(e),lr(this.mediaStreamTrack,e);const r=e.srcObject.getTracks(),o=r.some(l=>l.kind==="audio");return e.play().then(()=>{this.emit(o?W.AudioPlaybackStarted:W.VideoPlaybackStarted)}).catch(l=>{l.name==="NotAllowedError"?this.emit(o?W.AudioPlaybackFailed:W.VideoPlaybackFailed,l):l.name==="AbortError"?ke.debug("".concat(o?"audio":"video"," playback aborted, likely due to new play request")):ke.warn("could not playback ".concat(o?"audio":"video"),l),o&&e&&r.some(u=>u.kind==="video")&&l.name==="NotAllowedError"&&(e.muted=!0,e.play().catch(()=>{}))}),this.emit(W.ElementAttached,e),e}detach(e){try{if(e){fr(this.mediaStreamTrack,e);const r=this.attachedElements.indexOf(e);return r>=0&&(this.attachedElements.splice(r,1),this.recycleElement(e),this.emit(W.ElementDetached,e)),e}const n=[];return this.attachedElements.forEach(r=>{fr(this.mediaStreamTrack,r),n.push(r),this.recycleElement(r),this.emit(W.ElementDetached,r)}),this.attachedElements=[],n}finally{this.attachedElements.length===0&&this.removeAppVisibilityListener()}}stop(){this.stopMonitor(),this._mediaStreamTrack.stop()}enable(){this._mediaStreamTrack.enabled=!0}disable(){this._mediaStreamTrack.enabled=!1}stopMonitor(){this.monitorInterval&&clearInterval(this.monitorInterval),this.timeSyncHandle&&cancelAnimationFrame(this.timeSyncHandle)}updateLoggerOptions(e){e.loggerName&&(this.log=ei(e.loggerName)),e.loggerContextCb&&(this.loggerContextCb=e.loggerContextCb)}recycleElement(e){if(e instanceof HTMLAudioElement){let n=!0;e.pause(),Ds.forEach(r=>{r.parentElement||(n=!1)}),n&&Ds.push(e)}}handleAppVisibilityChanged(){return R(this,void 0,void 0,function*(){this.isInBackground=document.visibilityState==="hidden",!this.isInBackground&&this.kind===j.Kind.Video&&setTimeout(()=>this.attachedElements.forEach(e=>e.play().catch(()=>{})),0)})}addAppVisibilityListener(){xt()?(this.isInBackground=document.visibilityState==="hidden",document.addEventListener("visibilitychange",this.appVisibilityChangedListener)):this.isInBackground=!1}removeAppVisibilityListener(){xt()&&document.removeEventListener("visibilitychange",this.appVisibilityChangedListener)}}function lr(a,e){let n;e.srcObject instanceof MediaStream?n=e.srcObject:n=new MediaStream;let r;a.kind==="audio"?r=n.getAudioTracks():r=n.getVideoTracks(),r.includes(a)||(r.forEach(o=>{n.removeTrack(o)}),n.addTrack(a)),(!Bi()||!(e instanceof HTMLVideoElement))&&(e.autoplay=!0),e.muted=n.getAudioTracks().length===0,e instanceof HTMLVideoElement&&(e.playsInline=!0),e.srcObject!==n&&(e.srcObject=n,(Bi()||br())&&e instanceof HTMLVideoElement&&setTimeout(()=>{e.srcObject=n,e.play().catch(()=>{})},0))}function fr(a,e){if(e.srcObject instanceof MediaStream){const n=e.srcObject;n.removeTrack(a),n.getTracks().length>0?e.srcObject=n:e.srcObject=null}}(function(a){let e;(function(m){m.Audio="audio",m.Video="video",m.Unknown="unknown"})(e=a.Kind||(a.Kind={}));let n;(function(m){m.Camera="camera",m.Microphone="microphone",m.ScreenShare="screen_share",m.ScreenShareAudio="screen_share_audio",m.Unknown="unknown"})(n=a.Source||(a.Source={}));let r;(function(m){m.Active="active",m.Paused="paused",m.Unknown="unknown"})(r=a.StreamState||(a.StreamState={}));function o(m){switch(m){case e.Audio:return hn.AUDIO;case e.Video:return hn.VIDEO;default:return hn.DATA}}a.kindToProto=o;function l(m){switch(m){case hn.AUDIO:return e.Audio;case hn.VIDEO:return e.Video;default:return e.Unknown}}a.kindFromProto=l;function u(m){switch(m){case n.Camera:return ot.CAMERA;case n.Microphone:return ot.MICROPHONE;case n.ScreenShare:return ot.SCREEN_SHARE;case n.ScreenShareAudio:return ot.SCREEN_SHARE_AUDIO;default:return ot.UNKNOWN}}a.sourceToProto=u;function d(m){switch(m){case ot.CAMERA:return n.Camera;case ot.MICROPHONE:return n.Microphone;case ot.SCREEN_SHARE:return n.ScreenShare;case ot.SCREEN_SHARE_AUDIO:return n.ScreenShareAudio;default:return n.Unknown}}a.sourceFromProto=d;function h(m){switch(m){case Xd.ACTIVE:return r.Active;case Xd.PAUSED:return r.Paused;default:return r.Unknown}}a.streamStateFromProto=h})(j);class Ue{constructor(e,n,r,o,l){if(typeof e=="object")this.width=e.width,this.height=e.height,this.aspectRatio=e.aspectRatio,this.encoding={maxBitrate:e.maxBitrate,maxFramerate:e.maxFramerate,priority:e.priority};else if(n!==void 0&&r!==void 0)this.width=e,this.height=n,this.aspectRatio=e/n,this.encoding={maxBitrate:r,maxFramerate:o,priority:l};else throw new TypeError("Unsupported options: provide at least width, height and maxBitrate")}get resolution(){return{width:this.width,height:this.height,frameRate:this.encoding.maxFramerate,aspectRatio:this.aspectRatio}}}const UE=["vp8","h264"],LE=["vp8","h264","vp9","av1"];function IE(a){return!!UE.find(e=>e===a)}var Av;(function(a){a[a.REGRESSION=0]="REGRESSION",a[a.SIMULCAST=1]="SIMULCAST"})(Av||(Av={}));var cf;(function(a){a.telephone={maxBitrate:12e3},a.speech={maxBitrate:24e3},a.music={maxBitrate:48e3},a.musicStereo={maxBitrate:64e3},a.musicHighQuality={maxBitrate:96e3},a.musicHighQualityStereo={maxBitrate:128e3}})(cf||(cf={}));const Hs={h90:new Ue(160,90,9e4,20),h180:new Ue(320,180,16e4,20),h216:new Ue(384,216,18e4,20),h360:new Ue(640,360,45e4,20),h540:new Ue(960,540,8e5,25),h720:new Ue(1280,720,17e5,30),h1080:new Ue(1920,1080,3e6,30),h1440:new Ue(2560,1440,5e6,30),h2160:new Ue(3840,2160,8e6,30)},lf={h120:new Ue(160,120,7e4,20),h180:new Ue(240,180,125e3,20),h240:new Ue(320,240,14e4,20),h360:new Ue(480,360,33e4,20),h480:new Ue(640,480,5e5,20),h540:new Ue(720,540,6e5,25),h720:new Ue(960,720,13e5,30),h1080:new Ue(1440,1080,23e5,30),h1440:new Ue(1920,1440,38e5,30)},Hf={h360fps3:new Ue(640,360,2e5,3,"medium"),h360fps15:new Ue(640,360,4e5,15,"medium"),h720fps5:new Ue(1280,720,8e5,5,"medium"),h720fps15:new Ue(1280,720,15e5,15,"medium"),h720fps30:new Ue(1280,720,2e6,30,"medium"),h1080fps15:new Ue(1920,1080,25e5,15,"medium"),h1080fps30:new Ue(1920,1080,5e6,30,"medium"),original:new Ue(0,0,7e6,30,"medium")},jE="|",Mv="https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension";function BE(a){const e=a.split(jE);return e.length>1?[e[0],a.substr(e[0].length+1)]:[a,""]}function Nt(a){return R(this,void 0,void 0,function*(){return new Promise(e=>Tt.setTimeout(e,a))})}function uf(){return"addTransceiver"in RTCPeerConnection.prototype}function df(){return"addTrack"in RTCPeerConnection.prototype}function zE(){if(!("getCapabilities"in RTCRtpSender)||Bi())return!1;const a=RTCRtpSender.getCapabilities("video");let e=!1;if(a){for(const n of a.codecs)if(n.mimeType==="video/AV1"){e=!0;break}}return e}function qE(){if(!("getCapabilities"in RTCRtpSender)||br())return!1;if(Bi()){const n=Dn();if(n!=null&&n.version&&Sr(n.version,"16")<0)return!1}const a=RTCRtpSender.getCapabilities("video");let e=!1;if(a){for(const n of a.codecs)if(n.mimeType==="video/VP9"){e=!0;break}}return e}function Is(a){return a==="av1"||a==="vp9"}function ff(a){return document?(a||(a=document.createElement("audio")),"setSinkId"in a):!1}function VE(){return typeof RTCPeerConnection>"u"?!1:uf()||df()}function br(){var a;return((a=Dn())===null||a===void 0?void 0:a.name)==="Firefox"}function Bi(){var a;return((a=Dn())===null||a===void 0?void 0:a.name)==="Safari"}function HE(){const a=Dn();return(a==null?void 0:a.name)==="Safari"&&a.version.startsWith("17.")}function By(){var a,e;return xt()?(e=(a=navigator.userAgentData)===null||a===void 0?void 0:a.mobile)!==null&&e!==void 0?e:/Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent):!1}function GE(){const a=Dn(),e="17.2";if(a)return a.name!=="Safari"&&a.os!=="iOS"||a.os==="iOS"&&a.osVersion&&Sr(e,a.osVersion)>=0?!0:a.name==="Safari"&&Sr(e,a.version)>=0}function xt(){return typeof document<"u"}function An(){return navigator.product=="ReactNative"}function hf(a){return a.hostname.endsWith(".livekit.cloud")||a.hostname.endsWith(".livekit.run")}function zy(){if(global&&global.LiveKitReactNativeGlobal)return global.LiveKitReactNativeGlobal}function qy(){if(!An())return;let a=zy();if(a)return a.platform}function Pv(){if(xt())return window.devicePixelRatio;if(An()){let a=zy();if(a)return a.devicePixelRatio}return 1}function Sr(a,e){const n=a.split("."),r=e.split("."),o=Math.min(n.length,r.length);for(let l=0;l<o;++l){const u=parseInt(n[l],10),d=parseInt(r[l],10);if(u>d)return 1;if(u<d)return-1;if(l===o-1&&u===d)return 0}return a===""&&e!==""?-1:e===""?1:n.length==r.length?0:n.length<r.length?-1:1}function FE(a){for(const e of a)e.target.handleResize(e)}function YE(a){for(const e of a)e.target.handleVisibilityChanged(e)}let wd=null;const xv=()=>(wd||(wd=new ResizeObserver(FE)),wd);let Od=null;const Nv=()=>(Od||(Od=new IntersectionObserver(YE,{root:null,rootMargin:"0px"})),Od);function KE(){var a;const e=new UC({sdk:Y0.JS,protocol:xE,version:PE});return An()&&(e.os=(a=qy())!==null&&a!==void 0?a:""),e}function Uv(){let a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:16,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:16,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const o=document.createElement("canvas");o.width=a,o.height=e;const l=o.getContext("2d");l==null||l.fillRect(0,0,o.width,o.height),r&&l&&(l.beginPath(),l.arc(a/2,e/2,50,0,Math.PI*2,!0),l.closePath(),l.fillStyle="grey",l.fill());const u=o.captureStream(),[d]=u.getTracks();if(!d)throw Error("Could not get empty media stream video track");return d.enabled=n,d}let As;function Dd(){if(!As){const a=new AudioContext,e=a.createOscillator(),n=a.createGain();n.gain.setValueAtTime(0,0);const r=a.createMediaStreamDestination();if(e.connect(n),n.connect(r),e.start(),[As]=r.stream.getAudioTracks(),!As)throw Error("Could not get empty media stream audio track");As.enabled=!1}return As.clone()}class Vy{constructor(e,n){this.onFinally=n,this.promise=new Promise((r,o)=>R(this,void 0,void 0,function*(){this.resolve=r,this.reject=o,e&&(yield e(r,o))})).finally(()=>{var r;return(r=this.onFinally)===null||r===void 0?void 0:r.call(this)})}}function QE(a,e){const n=Object.assign({cloneTrack:!1,fftSize:2048,smoothingTimeConstant:.8,minDecibels:-100,maxDecibels:-80},e),r=Gf();if(!r)throw new Error("Audio Context not supported on this browser");const o=n.cloneTrack?a.mediaStreamTrack.clone():a.mediaStreamTrack,l=r.createMediaStreamSource(new MediaStream([o])),u=r.createAnalyser();u.minDecibels=n.minDecibels,u.maxDecibels=n.maxDecibels,u.fftSize=n.fftSize,u.smoothingTimeConstant=n.smoothingTimeConstant,l.connect(u);const d=new Uint8Array(u.frequencyBinCount);return{calculateVolume:()=>{u.getByteFrequencyData(d);let g=0;for(const b of d)g+=Math.pow(b/255,2);return Math.sqrt(g/d.length)},analyser:u,cleanup:()=>R(this,void 0,void 0,function*(){yield r.close(),n.cloneTrack&&o.stop()})}}function XE(a){return LE.includes(a)}function Ii(a){if(typeof a=="string"||typeof a=="number")return a;if(Array.isArray(a))return a[0];if(a.exact)return Array.isArray(a.exact)?a.exact[0]:a.exact;if(a.ideal)return Array.isArray(a.ideal)?a.ideal[0]:a.ideal;throw Error("could not unwrap constraint")}function ZE(a){return a.startsWith("http")?a.replace(/^(http)/,"ws"):a}function Lv(a){return a.startsWith("ws")?a.replace(/^(ws)/,"http"):a}function JE(a,e){return a.segments.map(n=>{let{id:r,text:o,language:l,startTime:u,endTime:d,final:h}=n;var m;const g=(m=e.get(r))!==null&&m!==void 0?m:Date.now(),y=Date.now();return h?e.delete(r):e.set(r,g),{id:r,text:o,startTime:Number.parseInt(u.toString()),endTime:Number.parseInt(d.toString()),final:h,language:l,firstReceivedTime:g,lastReceivedTime:y}})}function WE(a){const{id:e,timestamp:n,message:r,editTimestamp:o}=a;return{id:e,timestamp:Number.parseInt(n.toString()),editTimestamp:o?Number.parseInt(o.toString()):void 0,message:r}}function Iv(a){switch(a.reason){case Re.LeaveRequest:return a.context;case Re.Cancelled:return pn.CLIENT_INITIATED;case Re.NotAllowed:return pn.USER_REJECTED;case Re.ServerUnreachable:return pn.JOIN_FAILURE;default:return pn.UNKNOWN_REASON}}function Oc(a){return a!==void 0?Number(a):void 0}function fa(a){return a!==void 0?BigInt(a):void 0}function hr(a){return!!a&&!(a instanceof MediaStreamTrack)&&a.isLocal}function ti(a){return!!a&&a.kind==j.Kind.Audio}function Er(a){return!!a&&a.kind==j.Kind.Video}function Ai(a){return hr(a)&&Er(a)}function ha(a){return hr(a)&&ti(a)}function mf(a){return!!a&&!a.isLocal}function $E(a){return!!a&&!a.isLocal}function Ad(a){return mf(a)&&Er(a)}function e1(a){return a.isLocal}function t1(a,e){const n=[];let r=new TextEncoder().encode(a);for(;r.length>e;){let o=e;for(;o>0;){const l=r[o];if(l!==void 0&&(l&192)!==128)break;o--}n.push(r.slice(0,o)),r=r.slice(o)}return r.length>0&&n.push(r),n}function Hy(a,e,n){var r,o,l,u,d;const{optionsWithoutProcessor:h,audioProcessor:m,videoProcessor:g}=Ff(a??{}),y=e==null?void 0:e.processor,b=n==null?void 0:n.processor,T=(r=OE(h))!==null&&r!==void 0?r:{};return T.audio===!0&&(T.audio={}),T.video===!0&&(T.video={}),T.audio&&(pf(T.audio,e),(o=(u=T.audio).deviceId)!==null&&o!==void 0||(u.deviceId="default"),(m||y)&&(T.audio.processor=m??y)),T.video&&(pf(T.video,n),(l=(d=T.video).deviceId)!==null&&l!==void 0||(d.deviceId="default"),(g||b)&&(T.video.processor=g??b)),T}function pf(a,e){return Object.keys(e).forEach(n=>{a[n]===void 0&&(a[n]=e[n])}),a}function Qc(a){var e,n,r,o;const l={};if(a.video)if(typeof a.video=="object"){const u={},d=u,h=a.video;Object.keys(h).forEach(m=>{switch(m){case"resolution":pf(d,h.resolution);break;default:d[m]=h[m]}}),l.video=u,(e=(r=l.video).deviceId)!==null&&e!==void 0||(r.deviceId="default")}else l.video=a.video?{deviceId:"default"}:!1;else l.video=!1;return a.audio?typeof a.audio=="object"?(l.audio=a.audio,(n=(o=l.audio).deviceId)!==null&&n!==void 0||(o.deviceId="default")):l.audio={deviceId:"default"}:l.audio=!1,l}function Gy(a){return R(this,arguments,void 0,function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:200;return function*(){const r=Gf();if(r){const o=r.createAnalyser();o.fftSize=2048;const l=o.frequencyBinCount,u=new Uint8Array(l);r.createMediaStreamSource(new MediaStream([e.mediaStreamTrack])).connect(o),yield Nt(n),o.getByteTimeDomainData(u);const h=u.some(m=>m!==128&&m!==0);return r.close(),!h}return!1}()})}function Gf(){var a;const e=typeof window<"u"&&(window.AudioContext||window.webkitAudioContext);if(e){const n=new e({latencyHint:"interactive"});if(n.state==="suspended"&&typeof window<"u"&&(!((a=window.document)===null||a===void 0)&&a.body)){const r=()=>{n.resume().then(()=>{var o;(o=window.document.body)===null||o===void 0||o.removeEventListener("click",r)})};window.document.body.addEventListener("click",r)}return n}}function jv(a){return a===j.Source.Microphone?"audioinput":a===j.Source.Camera?"videoinput":void 0}function n1(a){var e,n;let r=(e=a.video)!==null&&e!==void 0?e:!0;return a.resolution&&a.resolution.width>0&&a.resolution.height>0&&(r=typeof r=="boolean"?{}:r,Bi()?r=Object.assign(Object.assign({},r),{width:{max:a.resolution.width},height:{max:a.resolution.height},frameRate:a.resolution.frameRate}):r=Object.assign(Object.assign({},r),{width:{ideal:a.resolution.width},height:{ideal:a.resolution.height},frameRate:a.resolution.frameRate})),{audio:(n=a.audio)!==null&&n!==void 0?n:!1,video:r,controller:a.controller,selfBrowserSurface:a.selfBrowserSurface,surfaceSwitching:a.surfaceSwitching,systemAudio:a.systemAudio,preferCurrentTab:a.preferCurrentTab}}function Dc(a){return a.split("/")[1].toLowerCase()}function i1(a){const e=[];return a.forEach(n=>{n.track!==void 0&&e.push(new jf({cid:n.track.mediaStreamID,track:n.trackInfo}))}),e}function Me(a){return"mediaStreamTrack"in a?{trackID:a.sid,source:a.source,muted:a.isMuted,enabled:a.mediaStreamTrack.enabled,kind:a.kind,streamID:a.mediaStreamID,streamTrackID:a.mediaStreamTrack.id}:{trackID:a.trackSid,enabled:a.isEnabled,muted:a.isMuted,trackInfo:Object.assign({mimeType:a.mimeType,name:a.trackName,encrypted:a.isEncrypted,kind:a.kind,source:a.source},a.track?Me(a.track):{})}}function a1(){return typeof RTCRtpReceiver<"u"&&"getSynchronizationSources"in RTCRtpReceiver}function r1(a,e){var n;a===void 0&&(a={}),e===void 0&&(e={});const r=[...Object.keys(e),...Object.keys(a)],o={};for(const l of r)a[l]!==e[l]&&(o[l]=(n=e[l])!==null&&n!==void 0?n:"");return o}function Ff(a){const e=Object.assign({},a);let n,r;return typeof e.audio=="object"&&e.audio.processor&&(n=e.audio.processor,e.audio=Object.assign(Object.assign({},e.audio),{processor:void 0})),typeof e.video=="object"&&e.video.processor&&(r=e.video.processor,e.video=Object.assign(Object.assign({},e.video),{processor:void 0})),{audioProcessor:n,videoProcessor:r,optionsWithoutProcessor:e}}function s1(a){switch(a){case ot.CAMERA:return j.Source.Camera;case ot.MICROPHONE:return j.Source.Microphone;case ot.SCREEN_SHARE:return j.Source.ScreenShare;case ot.SCREEN_SHARE_AUDIO:return j.Source.ScreenShareAudio;default:return j.Source.Unknown}}class o1 extends xn.EventEmitter{constructor(e){super(),this.onWorkerMessage=n=>{var r,o;const{kind:l,data:u}=n.data;switch(l){case"error":ke.error(u.error.message),this.emit(Ui.EncryptionError,u.error);break;case"initAck":u.enabled&&this.keyProvider.getKeys().forEach(d=>{this.postKey(d)});break;case"enable":if(u.enabled&&this.keyProvider.getKeys().forEach(d=>{this.postKey(d)}),this.encryptionEnabled!==u.enabled&&u.participantIdentity===((r=this.room)===null||r===void 0?void 0:r.localParticipant.identity))this.emit(Ui.ParticipantEncryptionStatusChanged,u.enabled,this.room.localParticipant),this.encryptionEnabled=u.enabled;else if(u.participantIdentity){const d=(o=this.room)===null||o===void 0?void 0:o.getParticipantByIdentity(u.participantIdentity);if(!d)throw TypeError("couldn't set encryption status, participant not found".concat(u.participantIdentity));this.emit(Ui.ParticipantEncryptionStatusChanged,u.enabled,d)}break;case"ratchetKey":this.keyProvider.emit(Li.KeyRatcheted,u.material,u.keyIndex);break}},this.onWorkerError=n=>{ke.error("e2ee worker encountered an error:",{error:n.error}),this.emit(Ui.EncryptionError,n.error)},this.keyProvider=e.keyProvider,this.worker=e.worker,this.encryptionEnabled=!1}setup(e){if(!EE())throw new Vf("tried to setup end-to-end encryption on an unsupported browser");if(ke.info("setting up e2ee"),e!==this.room){this.room=e,this.setupEventListeners(e,this.keyProvider);const n={kind:"init",data:{keyProviderOptions:this.keyProvider.getOptions(),loglevel:cE.getLevel()}};this.worker&&(ke.info("initializing worker",{worker:this.worker}),this.worker.onmessage=this.onWorkerMessage,this.worker.onerror=this.onWorkerError,this.worker.postMessage(n))}}setParticipantCryptorEnabled(e,n){ke.debug("set e2ee to ".concat(e," for participant ").concat(n)),this.postEnable(e,n)}setSifTrailer(e){!e||e.length===0?ke.warn("ignoring server sent trailer as it's empty"):this.postSifTrailer(e)}setupEngine(e){e.on(ne.RTPVideoMapUpdate,n=>{this.postRTPMap(n)})}setupEventListeners(e,n){e.on(B.TrackPublished,(r,o)=>this.setParticipantCryptorEnabled(r.trackInfo.encryption!==Vt.NONE,o.identity)),e.on(B.ConnectionStateChanged,r=>{r===Te.Connected&&e.remoteParticipants.forEach(o=>{o.trackPublications.forEach(l=>{this.setParticipantCryptorEnabled(l.trackInfo.encryption!==Vt.NONE,o.identity)})})}).on(B.TrackUnsubscribed,(r,o,l)=>{var u;const d={kind:"removeTransform",data:{participantIdentity:l.identity,trackId:r.mediaStreamID}};(u=this.worker)===null||u===void 0||u.postMessage(d)}).on(B.TrackSubscribed,(r,o,l)=>{this.setupE2EEReceiver(r,l.identity,o.trackInfo)}).on(B.SignalConnected,()=>{if(!this.room)throw new TypeError("expected room to be present on signal connect");n.getKeys().forEach(r=>{this.postKey(r)}),this.setParticipantCryptorEnabled(this.room.localParticipant.isE2EEEnabled,this.room.localParticipant.identity)}),e.localParticipant.on(F.LocalTrackPublished,r=>R(this,void 0,void 0,function*(){this.setupE2EESender(r.track,r.track.sender)})),n.on(Li.SetKey,r=>this.postKey(r)).on(Li.RatchetRequest,(r,o)=>this.postRatchetRequest(r,o))}postRatchetRequest(e,n){if(!this.worker)throw Error("could not ratchet key, worker is missing");const r={kind:"ratchetRequest",data:{participantIdentity:e,keyIndex:n}};this.worker.postMessage(r)}postKey(e){let{key:n,participantIdentity:r,keyIndex:o}=e;var l;if(!this.worker)throw Error("could not set key, worker is missing");const u={kind:"setKey",data:{participantIdentity:r,isPublisher:r===((l=this.room)===null||l===void 0?void 0:l.localParticipant.identity),key:n,keyIndex:o}};this.worker.postMessage(u)}postEnable(e,n){if(this.worker){const r={kind:"enable",data:{enabled:e,participantIdentity:n}};this.worker.postMessage(r)}else throw new ReferenceError("failed to enable e2ee, worker is not ready")}postRTPMap(e){var n;if(!this.worker)throw TypeError("could not post rtp map, worker is missing");if(!(!((n=this.room)===null||n===void 0)&&n.localParticipant.identity))throw TypeError("could not post rtp map, local participant identity is missing");const r={kind:"setRTPMap",data:{map:e,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(r)}postSifTrailer(e){if(!this.worker)throw Error("could not post SIF trailer, worker is missing");const n={kind:"setSifTrailer",data:{trailer:e}};this.worker.postMessage(n)}setupE2EEReceiver(e,n,r){if(e.receiver){if(!(r!=null&&r.mimeType)||r.mimeType==="")throw new TypeError("MimeType missing from trackInfo, cannot set up E2EE cryptor");this.handleReceiver(e.receiver,e.mediaStreamID,n,e.kind==="video"?Dc(r.mimeType):void 0)}}setupE2EESender(e,n){if(!hr(e)||!n){n||ke.warn("early return because sender is not ready");return}this.handleSender(n,e.mediaStreamID,void 0)}handleReceiver(e,n,r,o){return R(this,void 0,void 0,function*(){if(this.worker){if(sf()){const l={kind:"decode",participantIdentity:r,trackId:n,codec:o};e.transform=new RTCRtpScriptTransform(this.worker,l)}else{if(fc in e&&o){const h={kind:"updateCodec",data:{trackId:n,codec:o,participantIdentity:r}};this.worker.postMessage(h);return}let l=e.writableStream,u=e.readableStream;if(!l||!u){const h=e.createEncodedStreams();e.writableStream=h.writable,l=h.writable,e.readableStream=h.readable,u=h.readable}const d={kind:"decode",data:{readableStream:u,writableStream:l,trackId:n,codec:o,participantIdentity:r}};this.worker.postMessage(d,[u,l])}e[fc]=!0}})}handleSender(e,n,r){var o;if(!(fc in e||!this.worker)){if(!(!((o=this.room)===null||o===void 0)&&o.localParticipant.identity)||this.room.localParticipant.identity==="")throw TypeError("local identity needs to be known in order to set up encrypted sender");if(sf()){ke.info("initialize script transform");const l={kind:"encode",participantIdentity:this.room.localParticipant.identity,trackId:n,codec:r};e.transform=new RTCRtpScriptTransform(this.worker,l)}else{ke.info("initialize encoded streams");const l=e.createEncodedStreams(),u={kind:"encode",data:{readableStream:l.readable,writableStream:l.writable,codec:r,trackId:n,participantIdentity:this.room.localParticipant.identity}};this.worker.postMessage(u,[l.readable,l.writable])}e[fc]=!0}}}const Md="default";class gt{constructor(){this._previousDevices=[]}static getInstance(){return this.instance===void 0&&(this.instance=new gt),this.instance}get previousDevices(){return this._previousDevices}getDevices(e){return R(this,arguments,void 0,function(n){var r=this;let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var l;if(((l=gt.userMediaPromiseMap)===null||l===void 0?void 0:l.size)>0){ke.debug("awaiting getUserMedia promise");try{n?yield gt.userMediaPromiseMap.get(n):yield Promise.all(gt.userMediaPromiseMap.values())}catch{ke.warn("error waiting for media permissons")}}let u=yield navigator.mediaDevices.enumerateDevices();if(o&&!(Bi()&&r.hasDeviceInUse(n))&&(u.filter(h=>h.kind===n).length===0||u.some(h=>{const m=h.label==="",g=n?h.kind===n:!0;return m&&g}))){const h={video:n!=="audioinput"&&n!=="audiooutput",audio:n!=="videoinput"&&{deviceId:"default"}},m=yield navigator.mediaDevices.getUserMedia(h);u=yield navigator.mediaDevices.enumerateDevices(),m.getTracks().forEach(g=>{g.stop()})}return r._previousDevices=u,n&&(u=u.filter(d=>d.kind===n)),u}()})}normalizeDeviceId(e,n,r){return R(this,void 0,void 0,function*(){if(n!==Md)return n;const o=yield this.getDevices(e),l=o.find(d=>d.deviceId===Md);if(!l){ke.warn("could not reliably determine default device");return}const u=o.find(d=>d.deviceId!==Md&&d.groupId===(r??l.groupId));if(!u){ke.warn("could not reliably determine default device");return}return u==null?void 0:u.deviceId})}hasDeviceInUse(e){return e?gt.userMediaPromiseMap.has(e):gt.userMediaPromiseMap.size>0}}gt.mediaDeviceKinds=["audioinput","audiooutput","videoinput"];gt.userMediaPromiseMap=new Map;var js;(function(a){a[a.WAITING=0]="WAITING",a[a.RUNNING=1]="RUNNING",a[a.COMPLETED=2]="COMPLETED"})(js||(js={}));class c1{constructor(){this.pendingTasks=new Map,this.taskMutex=new Ht,this.nextTaskIndex=0}run(e){return R(this,void 0,void 0,function*(){const n={id:this.nextTaskIndex++,enqueuedAt:Date.now(),status:js.WAITING};this.pendingTasks.set(n.id,n);const r=yield this.taskMutex.lock();try{return n.executedAt=Date.now(),n.status=js.RUNNING,yield e()}finally{n.status=js.COMPLETED,this.pendingTasks.delete(n.id),r()}})}flush(){return R(this,void 0,void 0,function*(){return this.run(()=>R(this,void 0,void 0,function*(){}))})}snapshot(){return Array.from(this.pendingTasks.values())}}const l1=["syncState","trickle","offer","answer","simulate","leave"];function u1(a){const e=l1.indexOf(a.case)>=0;return ke.trace("request allowed to bypass queue:",{canPass:e,req:a}),e}var He;(function(a){a[a.CONNECTING=0]="CONNECTING",a[a.CONNECTED=1]="CONNECTED",a[a.RECONNECTING=2]="RECONNECTING",a[a.DISCONNECTING=3]="DISCONNECTING",a[a.DISCONNECTED=4]="DISCONNECTED"})(He||(He={}));class Yf{get currentState(){return this.state}get isDisconnected(){return this.state===He.DISCONNECTING||this.state===He.DISCONNECTED}get isEstablishingConnection(){return this.state===He.CONNECTING||this.state===He.RECONNECTING}getNextRequestId(){return this._requestId+=1,this._requestId}constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r;this.rtt=0,this.state=He.DISCONNECTED,this.log=ke,this._requestId=0,this.resetCallbacks=()=>{this.onAnswer=void 0,this.onLeave=void 0,this.onLocalTrackPublished=void 0,this.onLocalTrackUnpublished=void 0,this.onNegotiateRequested=void 0,this.onOffer=void 0,this.onRemoteMuteChanged=void 0,this.onSubscribedQualityUpdate=void 0,this.onTokenRefresh=void 0,this.onTrickle=void 0,this.onClose=void 0},this.log=ei((r=n.loggerName)!==null&&r!==void 0?r:gn.Signal),this.loggerContextCb=n.loggerContextCb,this.useJSON=e,this.requestQueue=new c1,this.queuedRequests=[],this.closingLock=new Ht,this.connectionLock=new Ht,this.state=He.DISCONNECTED}get logContext(){var e,n;return(n=(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this))!==null&&n!==void 0?n:{}}join(e,n,r,o){return R(this,void 0,void 0,function*(){return this.state=He.CONNECTING,this.options=r,yield this.connect(e,n,r,o)})}reconnect(e,n,r,o){return R(this,void 0,void 0,function*(){if(!this.options){this.log.warn("attempted to reconnect without signal options being set, ignoring",this.logContext);return}return this.state=He.RECONNECTING,this.clearPingInterval(),yield this.connect(e,n,Object.assign(Object.assign({},this.options),{reconnect:!0,sid:r,reconnectReason:o}))})}connect(e,n,r,o){this.connectOptions=r;const l=new URL(ZE(e));l.pathname=l.pathname.replace(/\/$/,""),l.pathname+="/rtc";const u=KE(),d=d1(n,u,r);for(const[h,m]of d)l.searchParams.set(h,m);return new Promise((h,m)=>R(this,void 0,void 0,function*(){const g=yield this.connectionLock.lock();try{const y=()=>R(this,void 0,void 0,function*(){this.close(),clearTimeout(b),m(new Ie("room connection has been cancelled (signal)",Re.Cancelled))}),b=setTimeout(()=>{this.close(),m(new Ie("room connection has timed out (signal)",Re.ServerUnreachable))},r.websocketTimeout);o!=null&&o.aborted&&y(),o==null||o.addEventListener("abort",y);const T=new URL(l.toString());T.searchParams.has("access_token")&&T.searchParams.set("access_token","<redacted>"),this.log.debug("connecting to ".concat(T),Object.assign({reconnect:r.reconnect,reconnectReason:r.reconnectReason},this.logContext)),this.ws&&(yield this.close(!1)),this.ws=new WebSocket(l.toString()),this.ws.binaryType="arraybuffer",this.ws.onopen=()=>{clearTimeout(b)},this.ws.onerror=C=>R(this,void 0,void 0,function*(){if(this.state!==He.CONNECTED){this.state=He.DISCONNECTED,clearTimeout(b);try{const k=new URL(l.toString());k.protocol="http".concat(k.protocol.substring(2)),k.pathname+="/validate";const w=yield fetch(k);if(w.status.toFixed(0).startsWith("4")){const O=yield w.text();m(new Ie(O,Re.NotAllowed,w.status))}else m(new Ie("Internal error",Re.InternalError,w.status))}catch(k){m(new Ie(k instanceof Error?k.message:"server was not reachable",Re.ServerUnreachable))}return}this.handleWSError(C)}),this.ws.onmessage=C=>R(this,void 0,void 0,function*(){var k,w,O;let V;if(typeof C.data=="string"){const Q=JSON.parse(C.data);V=pv.fromJson(Q,{ignoreUnknownFields:!0})}else if(C.data instanceof ArrayBuffer)V=pv.fromBinary(new Uint8Array(C.data));else{this.log.error("could not decode websocket message: ".concat(typeof C.data),this.logContext);return}if(this.state!==He.CONNECTED){let Q=!1;if(((k=V.message)===null||k===void 0?void 0:k.case)==="join"?(this.state=He.CONNECTED,o==null||o.removeEventListener("abort",y),this.pingTimeoutDuration=V.message.value.pingTimeout,this.pingIntervalDuration=V.message.value.pingInterval,this.pingTimeoutDuration&&this.pingTimeoutDuration>0&&(this.log.debug("ping config",Object.assign(Object.assign({},this.logContext),{timeout:this.pingTimeoutDuration,interval:this.pingIntervalDuration})),this.startPingInterval()),h(V.message.value)):this.state===He.RECONNECTING&&V.message.case!=="leave"?(this.state=He.CONNECTED,o==null||o.removeEventListener("abort",y),this.startPingInterval(),((w=V.message)===null||w===void 0?void 0:w.case)==="reconnect"?h(V.message.value):(this.log.debug("declaring signal reconnected without reconnect response received",this.logContext),h(void 0),Q=!0)):this.isEstablishingConnection&&V.message.case==="leave"?m(new Ie("Received leave request while trying to (re)connect",Re.LeaveRequest,void 0,V.message.value.reason)):r.reconnect||m(new Ie("did not receive join response, got ".concat((O=V.message)===null||O===void 0?void 0:O.case," instead"),Re.InternalError)),!Q)return}this.signalLatency&&(yield Nt(this.signalLatency)),this.handleSignalResponse(V)}),this.ws.onclose=C=>{this.isEstablishingConnection&&m(new Ie("Websocket got closed during a (re)connection attempt",Re.InternalError)),this.log.warn("websocket closed",Object.assign(Object.assign({},this.logContext),{reason:C.reason,code:C.code,wasClean:C.wasClean,state:this.state})),this.handleOnClose(C.reason)}}finally{g()}}))}close(){return R(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){const r=yield e.closingLock.lock();try{if(e.clearPingInterval(),n&&(e.state=He.DISCONNECTING),e.ws){e.ws.onmessage=null,e.ws.onopen=null,e.ws.onclose=null;const o=new Promise(l=>{e.ws?e.ws.onclose=()=>{l()}:l()});e.ws.readyState<e.ws.CLOSING&&(e.ws.close(),yield Promise.race([o,Nt(250)])),e.ws=void 0}}finally{n&&(e.state=He.DISCONNECTED),r()}}()})}sendOffer(e){this.log.debug("sending offer",Object.assign(Object.assign({},this.logContext),{offerSdp:e.sdp})),this.sendRequest({case:"offer",value:Nc(e)})}sendAnswer(e){return this.log.debug("sending answer",Object.assign(Object.assign({},this.logContext),{answerSdp:e.sdp})),this.sendRequest({case:"answer",value:Nc(e)})}sendIceCandidate(e,n){return this.log.debug("sending ice candidate",Object.assign(Object.assign({},this.logContext),{candidate:e})),this.sendRequest({case:"trickle",value:new Lf({candidateInit:JSON.stringify(e),target:n})})}sendMuteTrack(e,n){return this.sendRequest({case:"mute",value:new If({sid:e,muted:n})})}sendAddTrack(e){return this.sendRequest({case:"addTrack",value:e})}sendUpdateLocalMetadata(e,n){return R(this,arguments,void 0,function(r,o){var l=this;let u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function*(){const d=l.getNextRequestId();return yield l.sendRequest({case:"updateMetadata",value:new ey({requestId:d,metadata:r,name:o,attributes:u})}),d}()})}sendUpdateTrackSettings(e){this.sendRequest({case:"trackSetting",value:e})}sendUpdateSubscription(e){return this.sendRequest({case:"subscription",value:e})}sendSyncState(e){return this.sendRequest({case:"syncState",value:e})}sendUpdateVideoLayers(e,n){return this.sendRequest({case:"updateLayers",value:new $0({trackSid:e,layers:n})})}sendUpdateSubscriptionPermissions(e,n){return this.sendRequest({case:"subscriptionPermission",value:new iy({allParticipants:e,trackPermissions:n})})}sendSimulateScenario(e){return this.sendRequest({case:"simulate",value:e})}sendPing(){return Promise.all([this.sendRequest({case:"ping",value:Ge.parse(Date.now())}),this.sendRequest({case:"pingReq",value:new sy({timestamp:Ge.parse(Date.now()),rtt:Ge.parse(this.rtt)})})])}sendUpdateLocalAudioTrack(e,n){return this.sendRequest({case:"updateAudioTrack",value:new W0({trackSid:e,features:n})})}sendLeave(){return this.sendRequest({case:"leave",value:new Yc({reason:pn.CLIENT_INITIATED,action:ur.DISCONNECT})})}sendRequest(e){return R(this,arguments,void 0,function(n){var r=this;let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return function*(){if(!o&&!u1(n)&&r.state===He.RECONNECTING){r.queuedRequests.push(()=>R(r,void 0,void 0,function*(){yield this.sendRequest(n,!0)}));return}if(o||(yield r.requestQueue.flush()),r.signalLatency&&(yield Nt(r.signalLatency)),!r.ws||r.ws.readyState!==r.ws.OPEN){r.log.error("cannot send signal request before connected, type: ".concat(n==null?void 0:n.case),r.logContext);return}const u=new jC({message:n});try{r.useJSON?r.ws.send(u.toJsonString()):r.ws.send(u.toBinary())}catch(d){r.log.error("error sending signal message",Object.assign(Object.assign({},r.logContext),{error:d}))}}()})}handleSignalResponse(e){var n,r;const o=e.message;if(o==null){this.log.debug("received unsupported message",this.logContext);return}let l=!1;if(o.case==="answer"){const u=Bv(o.value);this.onAnswer&&this.onAnswer(u)}else if(o.case==="offer"){const u=Bv(o.value);this.onOffer&&this.onOffer(u)}else if(o.case==="trickle"){const u=JSON.parse(o.value.candidateInit);this.onTrickle&&this.onTrickle(u,o.value.target)}else o.case==="update"?this.onParticipantUpdate&&this.onParticipantUpdate((n=o.value.participants)!==null&&n!==void 0?n:[]):o.case==="trackPublished"?this.onLocalTrackPublished&&this.onLocalTrackPublished(o.value):o.case==="speakersChanged"?this.onSpeakersChanged&&this.onSpeakersChanged((r=o.value.speakers)!==null&&r!==void 0?r:[]):o.case==="leave"?this.onLeave&&this.onLeave(o.value):o.case==="mute"?this.onRemoteMuteChanged&&this.onRemoteMuteChanged(o.value.sid,o.value.muted):o.case==="roomUpdate"?this.onRoomUpdate&&o.value.room&&this.onRoomUpdate(o.value.room):o.case==="connectionQuality"?this.onConnectionQuality&&this.onConnectionQuality(o.value):o.case==="streamStateUpdate"?this.onStreamStateUpdate&&this.onStreamStateUpdate(o.value):o.case==="subscribedQualityUpdate"?this.onSubscribedQualityUpdate&&this.onSubscribedQualityUpdate(o.value):o.case==="subscriptionPermissionUpdate"?this.onSubscriptionPermissionUpdate&&this.onSubscriptionPermissionUpdate(o.value):o.case==="refreshToken"?this.onTokenRefresh&&this.onTokenRefresh(o.value):o.case==="trackUnpublished"?this.onLocalTrackUnpublished&&this.onLocalTrackUnpublished(o.value):o.case==="subscriptionResponse"?this.onSubscriptionError&&this.onSubscriptionError(o.value):o.case==="pong"||(o.case==="pongResp"?(this.rtt=Date.now()-Number.parseInt(o.value.lastPingTimestamp.toString()),this.resetPingTimeout(),l=!0):o.case==="requestResponse"?this.onRequestResponse&&this.onRequestResponse(o.value):o.case==="trackSubscribed"?this.onLocalTrackSubscribed&&this.onLocalTrackSubscribed(o.value.trackSid):this.log.debug("unsupported message",Object.assign(Object.assign({},this.logContext),{msgCase:o.case})));l||this.resetPingTimeout()}setReconnected(){for(;this.queuedRequests.length>0;){const e=this.queuedRequests.shift();e&&this.requestQueue.run(e)}}handleOnClose(e){return R(this,void 0,void 0,function*(){if(this.state===He.DISCONNECTED)return;const n=this.onClose;yield this.close(),this.log.debug("websocket connection closed: ".concat(e),Object.assign(Object.assign({},this.logContext),{reason:e})),n&&n(e)})}handleWSError(e){this.log.error("websocket error",Object.assign(Object.assign({},this.logContext),{error:e}))}resetPingTimeout(){if(this.clearPingTimeout(),!this.pingTimeoutDuration){this.log.warn("ping timeout duration not set",this.logContext);return}this.pingTimeout=Tt.setTimeout(()=>{this.log.warn("ping timeout triggered. last pong received at: ".concat(new Date(Date.now()-this.pingTimeoutDuration*1e3).toUTCString()),this.logContext),this.handleOnClose("ping timeout")},this.pingTimeoutDuration*1e3)}clearPingTimeout(){this.pingTimeout&&Tt.clearTimeout(this.pingTimeout)}startPingInterval(){if(this.clearPingInterval(),this.resetPingTimeout(),!this.pingIntervalDuration){this.log.warn("ping interval duration not set",this.logContext);return}this.log.debug("start ping interval",this.logContext),this.pingInterval=Tt.setInterval(()=>{this.sendPing()},this.pingIntervalDuration*1e3)}clearPingInterval(){this.log.debug("clearing ping interval",this.logContext),this.clearPingTimeout(),this.pingInterval&&Tt.clearInterval(this.pingInterval)}}function Bv(a){const e={type:"offer",sdp:a.sdp};switch(a.type){case"answer":case"offer":case"pranswer":case"rollback":e.type=a.type;break}return e}function Nc(a){return new va({sdp:a.sdp,type:a.type})}function d1(a,e,n){var r;const o=new URLSearchParams;return o.set("access_token",a),n.reconnect&&(o.set("reconnect","1"),n.sid&&o.set("sid",n.sid)),o.set("auto_subscribe",n.autoSubscribe?"1":"0"),o.set("sdk",An()?"reactnative":"js"),o.set("version",e.version),o.set("protocol",e.protocol.toString()),e.deviceModel&&o.set("device_model",e.deviceModel),e.os&&o.set("os",e.os),e.osVersion&&o.set("os_version",e.osVersion),e.browser&&o.set("browser",e.browser),e.browserVersion&&o.set("browser_version",e.browserVersion),n.adaptiveStream&&o.set("adaptive_stream","1"),n.reconnectReason&&o.set("reconnect_reason",n.reconnectReason.toString()),!((r=navigator.connection)===null||r===void 0)&&r.type&&o.set("network",navigator.connection.type),o}var un={},Pd={},xd={exports:{}},zv;function Kf(){if(zv)return xd.exports;zv=1;var a=xd.exports={v:[{name:"version",reg:/^(\d*)$/}],o:[{name:"origin",reg:/^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,names:["username","sessionId","sessionVersion","netType","ipVer","address"],format:"%s %s %d %s IP%d %s"}],s:[{name:"name"}],i:[{name:"description"}],u:[{name:"uri"}],e:[{name:"email"}],p:[{name:"phone"}],z:[{name:"timezones"}],r:[{name:"repeats"}],t:[{name:"timing",reg:/^(\d*) (\d*)/,names:["start","stop"],format:"%d %d"}],c:[{name:"connection",reg:/^IN IP(\d) (\S*)/,names:["version","ip"],format:"IN IP%d %s"}],b:[{push:"bandwidth",reg:/^(TIAS|AS|CT|RR|RS):(\d*)/,names:["type","limit"],format:"%s:%s"}],m:[{reg:/^(\w*) (\d*) ([\w/]*)(?: (.*))?/,names:["type","port","protocol","payloads"],format:"%s %d %s %s"}],a:[{push:"rtp",reg:/^rtpmap:(\d*) ([\w\-.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,names:["payload","codec","rate","encoding"],format:function(e){return e.encoding?"rtpmap:%d %s/%s/%s":e.rate?"rtpmap:%d %s/%s":"rtpmap:%d %s"}},{push:"fmtp",reg:/^fmtp:(\d*) ([\S| ]*)/,names:["payload","config"],format:"fmtp:%d %s"},{name:"control",reg:/^control:(.*)/,format:"control:%s"},{name:"rtcp",reg:/^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,names:["port","netType","ipVer","address"],format:function(e){return e.address!=null?"rtcp:%d %s IP%d %s":"rtcp:%d"}},{push:"rtcpFbTrrInt",reg:/^rtcp-fb:(\*|\d*) trr-int (\d*)/,names:["payload","value"],format:"rtcp-fb:%s trr-int %d"},{push:"rtcpFb",reg:/^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,names:["payload","type","subtype"],format:function(e){return e.subtype!=null?"rtcp-fb:%s %s %s":"rtcp-fb:%s %s"}},{push:"ext",reg:/^extmap:(\d+)(?:\/(\w+))?(?: (urn:ietf:params:rtp-hdrext:encrypt))? (\S*)(?: (\S*))?/,names:["value","direction","encrypt-uri","uri","config"],format:function(e){return"extmap:%d"+(e.direction?"/%s":"%v")+(e["encrypt-uri"]?" %s":"%v")+" %s"+(e.config?" %s":"")}},{name:"extmapAllowMixed",reg:/^(extmap-allow-mixed)/},{push:"crypto",reg:/^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,names:["id","suite","config","sessionConfig"],format:function(e){return e.sessionConfig!=null?"crypto:%d %s %s %s":"crypto:%d %s %s"}},{name:"setup",reg:/^setup:(\w*)/,format:"setup:%s"},{name:"connectionType",reg:/^connection:(new|existing)/,format:"connection:%s"},{name:"mid",reg:/^mid:([^\s]*)/,format:"mid:%s"},{name:"msid",reg:/^msid:(.*)/,format:"msid:%s"},{name:"ptime",reg:/^ptime:(\d*(?:\.\d*)*)/,format:"ptime:%d"},{name:"maxptime",reg:/^maxptime:(\d*(?:\.\d*)*)/,format:"maxptime:%d"},{name:"direction",reg:/^(sendrecv|recvonly|sendonly|inactive)/},{name:"icelite",reg:/^(ice-lite)/},{name:"iceUfrag",reg:/^ice-ufrag:(\S*)/,format:"ice-ufrag:%s"},{name:"icePwd",reg:/^ice-pwd:(\S*)/,format:"ice-pwd:%s"},{name:"fingerprint",reg:/^fingerprint:(\S*) (\S*)/,names:["type","hash"],format:"fingerprint:%s %s"},{push:"candidates",reg:/^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,names:["foundation","component","transport","priority","ip","port","type","raddr","rport","tcptype","generation","network-id","network-cost"],format:function(e){var n="candidate:%s %d %s %d %s %d typ %s";return n+=e.raddr!=null?" raddr %s rport %d":"%v%v",n+=e.tcptype!=null?" tcptype %s":"%v",e.generation!=null&&(n+=" generation %d"),n+=e["network-id"]!=null?" network-id %d":"%v",n+=e["network-cost"]!=null?" network-cost %d":"%v",n}},{name:"endOfCandidates",reg:/^(end-of-candidates)/},{name:"remoteCandidates",reg:/^remote-candidates:(.*)/,format:"remote-candidates:%s"},{name:"iceOptions",reg:/^ice-options:(\S*)/,format:"ice-options:%s"},{push:"ssrcs",reg:/^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,names:["id","attribute","value"],format:function(e){var n="ssrc:%d";return e.attribute!=null&&(n+=" %s",e.value!=null&&(n+=":%s")),n}},{push:"ssrcGroups",reg:/^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,names:["semantics","ssrcs"],format:"ssrc-group:%s %s"},{name:"msidSemantic",reg:/^msid-semantic:\s?(\w*) (\S*)/,names:["semantic","token"],format:"msid-semantic: %s %s"},{push:"groups",reg:/^group:(\w*) (.*)/,names:["type","mids"],format:"group:%s %s"},{name:"rtcpMux",reg:/^(rtcp-mux)/},{name:"rtcpRsize",reg:/^(rtcp-rsize)/},{name:"sctpmap",reg:/^sctpmap:([\w_/]*) (\S*)(?: (\S*))?/,names:["sctpmapNumber","app","maxMessageSize"],format:function(e){return e.maxMessageSize!=null?"sctpmap:%s %s %s":"sctpmap:%s %s"}},{name:"xGoogleFlag",reg:/^x-google-flag:([^\s]*)/,format:"x-google-flag:%s"},{push:"rids",reg:/^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,names:["id","direction","params"],format:function(e){return e.params?"rid:%s %s %s":"rid:%s %s"}},{push:"imageattrs",reg:new RegExp("^imageattr:(\\d+|\\*)[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?"),names:["pt","dir1","attrs1","dir2","attrs2"],format:function(e){return"imageattr:%s %s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast",reg:new RegExp("^simulcast:(send|recv) ([a-zA-Z0-9\\-_~;,]+)(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?$"),names:["dir1","list1","dir2","list2"],format:function(e){return"simulcast:%s %s"+(e.dir2?" %s %s":"")}},{name:"simulcast_03",reg:/^simulcast:[\s\t]+([\S+\s\t]+)$/,names:["value"],format:"simulcast: %s"},{name:"framerate",reg:/^framerate:(\d+(?:$|\.\d+))/,format:"framerate:%s"},{name:"sourceFilter",reg:/^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,names:["filterMode","netType","addressTypes","destAddress","srcList"],format:"source-filter: %s %s %s %s %s"},{name:"bundleOnly",reg:/^(bundle-only)/},{name:"label",reg:/^label:(.+)/,format:"label:%s"},{name:"sctpPort",reg:/^sctp-port:(\d+)$/,format:"sctp-port:%s"},{name:"maxMessageSize",reg:/^max-message-size:(\d+)$/,format:"max-message-size:%s"},{push:"tsRefClocks",reg:/^ts-refclk:([^\s=]*)(?:=(\S*))?/,names:["clksrc","clksrcExt"],format:function(e){return"ts-refclk:%s"+(e.clksrcExt!=null?"=%s":"")}},{name:"mediaClk",reg:/^mediaclk:(?:id=(\S*))? *([^\s=]*)(?:=(\S*))?(?: *rate=(\d+)\/(\d+))?/,names:["id","mediaClockName","mediaClockValue","rateNumerator","rateDenominator"],format:function(e){var n="mediaclk:";return n+=e.id!=null?"id=%s %s":"%v%s",n+=e.mediaClockValue!=null?"=%s":"",n+=e.rateNumerator!=null?" rate=%s":"",n+=e.rateDenominator!=null?"/%s":"",n}},{name:"keywords",reg:/^keywds:(.+)$/,format:"keywds:%s"},{name:"content",reg:/^content:(.+)/,format:"content:%s"},{name:"bfcpFloorCtrl",reg:/^floorctrl:(c-only|s-only|c-s)/,format:"floorctrl:%s"},{name:"bfcpConfId",reg:/^confid:(\d+)/,format:"confid:%s"},{name:"bfcpUserId",reg:/^userid:(\d+)/,format:"userid:%s"},{name:"bfcpFloorId",reg:/^floorid:(.+) (?:m-stream|mstrm):(.+)/,names:["id","mStream"],format:"floorid:%s mstrm:%s"},{push:"invalid",names:["value"]}]};return Object.keys(a).forEach(function(e){var n=a[e];n.forEach(function(r){r.reg||(r.reg=/(.*)/),r.format||(r.format="%s")})}),xd.exports}var qv;function f1(){return qv||(qv=1,function(a){var e=function(d){return String(Number(d))===d?Number(d):d},n=function(d,h,m,g){if(g&&!m)h[g]=e(d[1]);else for(var y=0;y<m.length;y+=1)d[y+1]!=null&&(h[m[y]]=e(d[y+1]))},r=function(d,h,m){var g=d.name&&d.names;d.push&&!h[d.push]?h[d.push]=[]:g&&!h[d.name]&&(h[d.name]={});var y=d.push?{}:g?h[d.name]:h;n(m.match(d.reg),y,d.names,d.name),d.push&&h[d.push].push(y)},o=Kf(),l=RegExp.prototype.test.bind(/^([a-z])=(.*)/);a.parse=function(d){var h={},m=[],g=h;return d.split(/(\r\n|\r|\n)/).filter(l).forEach(function(y){var b=y[0],T=y.slice(2);b==="m"&&(m.push({rtp:[],fmtp:[]}),g=m[m.length-1]);for(var C=0;C<(o[b]||[]).length;C+=1){var k=o[b][C];if(k.reg.test(T))return r(k,g,T)}}),h.media=m,h};var u=function(d,h){var m=h.split(/=(.+)/,2);return m.length===2?d[m[0]]=e(m[1]):m.length===1&&h.length>1&&(d[m[0]]=void 0),d};a.parseParams=function(d){return d.split(/;\s?/).reduce(u,{})},a.parseFmtpConfig=a.parseParams,a.parsePayloads=function(d){return d.toString().split(" ").map(Number)},a.parseRemoteCandidates=function(d){for(var h=[],m=d.split(" ").map(e),g=0;g<m.length;g+=3)h.push({component:m[g],ip:m[g+1],port:m[g+2]});return h},a.parseImageAttributes=function(d){return d.split(" ").map(function(h){return h.substring(1,h.length-1).split(",").reduce(u,{})})},a.parseSimulcastStreamList=function(d){return d.split(";").map(function(h){return h.split(",").map(function(m){var g,y=!1;return m[0]!=="~"?g=e(m):(g=e(m.substring(1,m.length)),y=!0),{scid:g,paused:y}})})}}(Pd)),Pd}var Nd,Vv;function h1(){if(Vv)return Nd;Vv=1;var a=Kf(),e=/%[sdv%]/g,n=function(u){var d=1,h=arguments,m=h.length;return u.replace(e,function(g){if(d>=m)return g;var y=h[d];switch(d+=1,g){case"%%":return"%";case"%s":return String(y);case"%d":return Number(y);case"%v":return""}})},r=function(u,d,h){var m=d.format instanceof Function?d.format(d.push?h:h[d.name]):d.format,g=[u+"="+m];if(d.names)for(var y=0;y<d.names.length;y+=1){var b=d.names[y];d.name?g.push(h[d.name][b]):g.push(h[d.names[y]])}else g.push(h[d.name]);return n.apply(null,g)},o=["v","o","s","i","u","e","p","c","b","t","r","z","a"],l=["i","c","b","a"];return Nd=function(u,d){d=d||{},u.version==null&&(u.version=0),u.name==null&&(u.name=" "),u.media.forEach(function(y){y.payloads==null&&(y.payloads="")});var h=d.outerOrder||o,m=d.innerOrder||l,g=[];return h.forEach(function(y){a[y].forEach(function(b){b.name in u&&u[b.name]!=null?g.push(r(y,b,u)):b.push in u&&u[b.push]!=null&&u[b.push].forEach(function(T){g.push(r(y,b,T))})})}),u.media.forEach(function(y){g.push(r("m",a.m[0],y)),m.forEach(function(b){a[b].forEach(function(T){T.name in y&&y[T.name]!=null?g.push(r(b,T,y)):T.push in y&&y[T.push]!=null&&y[T.push].forEach(function(C){g.push(r(b,T,C))})})})}),g.join(`\r
`)+`\r
`},Nd}var Hv;function m1(){if(Hv)return un;Hv=1;var a=f1(),e=h1(),n=Kf();return un.grammar=n,un.write=e,un.parse=a.parse,un.parseParams=a.parseParams,un.parseFmtpConfig=a.parseFmtpConfig,un.parsePayloads=a.parsePayloads,un.parseRemoteCandidates=a.parseRemoteCandidates,un.parseImageAttributes=a.parseImageAttributes,un.parseSimulcastStreamList=a.parseSimulcastStreamList,un}var Mi=m1();function Qf(a,e,n){var r,o,l;e===void 0&&(e=50),n===void 0&&(n={});var u=(r=n.isImmediate)!=null&&r,d=(o=n.callback)!=null&&o,h=n.maxWait,m=Date.now(),g=[];function y(){if(h!==void 0){var T=Date.now()-m;if(T+e>=h)return h-T}return e}var b=function(){var T=[].slice.call(arguments),C=this;return new Promise(function(k,w){var O=u&&l===void 0;if(l!==void 0&&clearTimeout(l),l=setTimeout(function(){if(l=void 0,m=Date.now(),!u){var Q=a.apply(C,T);d&&d(Q),g.forEach(function(U){return(0,U.resolve)(Q)}),g=[]}},y()),O){var V=a.apply(C,T);return d&&d(V),k(V)}g.push({resolve:k,reject:w})})};return b.cancel=function(T){l!==void 0&&clearTimeout(l),g.forEach(function(C){return(0,C.reject)(T)}),g=[]},b}const p1=.7,g1=20,mr={NegotiationStarted:"negotiationStarted",NegotiationComplete:"negotiationComplete",RTPVideoPayloadTypes:"rtpVideoPayloadTypes"};class Gv extends xn.EventEmitter{get pc(){return this._pc||(this._pc=this.createPC()),this._pc}constructor(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};var r;super(),this.log=ke,this.ddExtID=0,this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate=!1,this.trackBitrates=[],this.remoteStereoMids=[],this.remoteNackMids=[],this.negotiate=Qf(o=>R(this,void 0,void 0,function*(){this.emit(mr.NegotiationStarted);try{yield this.createAndSendOffer()}catch(l){if(o)o(l);else throw l}}),g1),this.close=()=>{this._pc&&(this._pc.close(),this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.ondatachannel=null,this._pc.onnegotiationneeded=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ondatachannel=null,this._pc.ontrack=null,this._pc.onconnectionstatechange=null,this._pc.oniceconnectionstatechange=null,this._pc=null)},this.log=ei((r=n.loggerName)!==null&&r!==void 0?r:gn.PCTransport),this.loggerOptions=n,this.config=e,this._pc=this.createPC()}createPC(){const e=new RTCPeerConnection(this.config);return e.onicecandidate=n=>{var r;n.candidate&&((r=this.onIceCandidate)===null||r===void 0||r.call(this,n.candidate))},e.onicecandidateerror=n=>{var r;(r=this.onIceCandidateError)===null||r===void 0||r.call(this,n)},e.oniceconnectionstatechange=()=>{var n;(n=this.onIceConnectionStateChange)===null||n===void 0||n.call(this,e.iceConnectionState)},e.onsignalingstatechange=()=>{var n;(n=this.onSignalingStatechange)===null||n===void 0||n.call(this,e.signalingState)},e.onconnectionstatechange=()=>{var n;(n=this.onConnectionStateChange)===null||n===void 0||n.call(this,e.connectionState)},e.ondatachannel=n=>{var r;(r=this.onDataChannel)===null||r===void 0||r.call(this,n)},e.ontrack=n=>{var r;(r=this.onTrack)===null||r===void 0||r.call(this,n)},e}get logContext(){var e,n;return Object.assign({},(n=(e=this.loggerOptions).loggerContextCb)===null||n===void 0?void 0:n.call(e))}get isICEConnected(){return this._pc!==null&&(this.pc.iceConnectionState==="connected"||this.pc.iceConnectionState==="completed")}addIceCandidate(e){return R(this,void 0,void 0,function*(){if(this.pc.remoteDescription&&!this.restartingIce)return this.pc.addIceCandidate(e);this.pendingCandidates.push(e)})}setRemoteDescription(e){return R(this,void 0,void 0,function*(){var n;let r;if(e.type==="offer"){let{stereoMids:o,nackMids:l}=v1(e);this.remoteStereoMids=o,this.remoteNackMids=l}else if(e.type==="answer"){const o=Mi.parse((n=e.sdp)!==null&&n!==void 0?n:"");o.media.forEach(l=>{l.type==="audio"&&this.trackBitrates.some(u=>{if(!u.transceiver||l.mid!=u.transceiver.mid)return!1;let d=0;if(l.rtp.some(m=>m.codec.toUpperCase()===u.codec.toUpperCase()?(d=m.payload,!0):!1),d===0)return!0;let h=!1;for(const m of l.fmtp)if(m.payload===d){m.config=m.config.split(";").filter(g=>!g.includes("maxaveragebitrate")).join(";"),u.maxbr>0&&(m.config+=";maxaveragebitrate=".concat(u.maxbr*1e3)),h=!0;break}return h||u.maxbr>0&&l.fmtp.push({payload:d,config:"maxaveragebitrate=".concat(u.maxbr*1e3)}),!0})}),r=Mi.write(o)}yield this.setMungedSDP(e,r,!0),this.pendingCandidates.forEach(o=>{this.pc.addIceCandidate(o)}),this.pendingCandidates=[],this.restartingIce=!1,this.renegotiate?(this.renegotiate=!1,yield this.createAndSendOffer()):e.type==="answer"&&(this.emit(mr.NegotiationComplete),e.sdp&&Mi.parse(e.sdp).media.forEach(l=>{l.type==="video"&&this.emit(mr.RTPVideoPayloadTypes,l.rtp)}))})}createAndSendOffer(e){return R(this,void 0,void 0,function*(){var n;if(this.onOffer===void 0)return;if(e!=null&&e.iceRestart&&(this.log.debug("restarting ICE",this.logContext),this.restartingIce=!0),this._pc&&this._pc.signalingState==="have-local-offer"){const l=this._pc.remoteDescription;if(e!=null&&e.iceRestart&&l)yield this._pc.setRemoteDescription(l);else{this.renegotiate=!0;return}}else if(!this._pc||this._pc.signalingState==="closed"){this.log.warn("could not createOffer with closed peer connection",this.logContext);return}this.log.debug("starting to negotiate",this.logContext);const r=yield this.pc.createOffer(e);this.log.debug("original offer",Object.assign({sdp:r.sdp},this.logContext));const o=Mi.parse((n=r.sdp)!==null&&n!==void 0?n:"");o.media.forEach(l=>{Yv(l),l.type==="audio"?Fv(l,[],[]):l.type==="video"&&this.trackBitrates.some(u=>{if(!l.msid||!u.cid||!l.msid.includes(u.cid))return!1;let d=0;if(l.rtp.some(m=>m.codec.toUpperCase()===u.codec.toUpperCase()?(d=m.payload,!0):!1),d===0||(Is(u.codec)&&this.ensureVideoDDExtensionForSVC(l,o),u.codec!=="av1"))return!0;const h=Math.round(u.maxbr*p1);for(const m of l.fmtp)if(m.payload===d){m.config.includes("x-google-start-bitrate")||(m.config+=";x-google-start-bitrate=".concat(h));break}return!0})}),yield this.setMungedSDP(r,Mi.write(o)),this.onOffer(r)})}createAndSetAnswer(){return R(this,void 0,void 0,function*(){var e;const n=yield this.pc.createAnswer(),r=Mi.parse((e=n.sdp)!==null&&e!==void 0?e:"");return r.media.forEach(o=>{Yv(o),o.type==="audio"&&Fv(o,this.remoteStereoMids,this.remoteNackMids)}),yield this.setMungedSDP(n,Mi.write(r)),n})}createDataChannel(e,n){return this.pc.createDataChannel(e,n)}addTransceiver(e,n){return this.pc.addTransceiver(e,n)}addTrack(e){if(!this._pc)throw new ut("PC closed, cannot add track");return this._pc.addTrack(e)}setTrackCodecBitrate(e){this.trackBitrates.push(e)}setConfiguration(e){var n;if(!this._pc)throw new ut("PC closed, cannot configure");return(n=this._pc)===null||n===void 0?void 0:n.setConfiguration(e)}canRemoveTrack(){var e;return!!(!((e=this._pc)===null||e===void 0)&&e.removeTrack)}removeTrack(e){var n;return(n=this._pc)===null||n===void 0?void 0:n.removeTrack(e)}getConnectionState(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.connectionState)!==null&&n!==void 0?n:"closed"}getICEConnectionState(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.iceConnectionState)!==null&&n!==void 0?n:"closed"}getSignallingState(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.signalingState)!==null&&n!==void 0?n:"closed"}getTransceivers(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.getTransceivers())!==null&&n!==void 0?n:[]}getSenders(){var e,n;return(n=(e=this._pc)===null||e===void 0?void 0:e.getSenders())!==null&&n!==void 0?n:[]}getLocalDescription(){var e;return(e=this._pc)===null||e===void 0?void 0:e.localDescription}getRemoteDescription(){var e;return(e=this.pc)===null||e===void 0?void 0:e.remoteDescription}getStats(){return this.pc.getStats()}getConnectedAddress(){return R(this,void 0,void 0,function*(){var e;if(!this._pc)return;let n="";const r=new Map,o=new Map;if((yield this._pc.getStats()).forEach(d=>{switch(d.type){case"transport":n=d.selectedCandidatePairId;break;case"candidate-pair":n===""&&d.selected&&(n=d.id),r.set(d.id,d);break;case"remote-candidate":o.set(d.id,"".concat(d.address,":").concat(d.port));break}}),n==="")return;const u=(e=r.get(n))===null||e===void 0?void 0:e.remoteCandidateId;if(u!==void 0)return o.get(u)})}setMungedSDP(e,n,r){return R(this,void 0,void 0,function*(){if(n){const o=e.sdp;e.sdp=n;try{this.log.debug("setting munged ".concat(r?"remote":"local"," description"),this.logContext),r?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e);return}catch(l){this.log.warn("not able to set ".concat(e.type,", falling back to unmodified sdp"),Object.assign(Object.assign({},this.logContext),{error:l,sdp:n})),e.sdp=o}}try{r?yield this.pc.setRemoteDescription(e):yield this.pc.setLocalDescription(e)}catch(o){let l="unknown error";o instanceof Error?l=o.message:typeof o=="string"&&(l=o);const u={error:l,sdp:e.sdp};throw!r&&this.pc.remoteDescription&&(u.remoteSdp=this.pc.remoteDescription),this.log.error("unable to set ".concat(e.type),Object.assign(Object.assign({},this.logContext),{fields:u})),new of(l)}})}ensureVideoDDExtensionForSVC(e,n){var r,o;if(!((r=e.ext)===null||r===void 0?void 0:r.some(u=>u.uri===Mv))){if(this.ddExtID===0){let u=0;n.media.forEach(d=>{var h;d.type==="video"&&((h=d.ext)===null||h===void 0||h.forEach(m=>{m.value>u&&(u=m.value)}))}),this.ddExtID=u+1}(o=e.ext)===null||o===void 0||o.push({value:this.ddExtID,uri:Mv})}}}function Fv(a,e,n){let r=0;a.rtp.some(o=>o.codec==="opus"?(r=o.payload,!0):!1),r>0&&(a.rtcpFb||(a.rtcpFb=[]),n.includes(a.mid)&&!a.rtcpFb.some(o=>o.payload===r&&o.type==="nack")&&a.rtcpFb.push({payload:r,type:"nack"}),e.includes(a.mid)&&a.fmtp.some(o=>o.payload===r?(o.config.includes("stereo=1")||(o.config+=";stereo=1"),!0):!1))}function v1(a){var e;const n=[],r=[],o=Mi.parse((e=a.sdp)!==null&&e!==void 0?e:"");let l=0;return o.media.forEach(u=>{var d;u.type==="audio"&&(u.rtp.some(h=>h.codec==="opus"?(l=h.payload,!0):!1),!((d=u.rtcpFb)===null||d===void 0)&&d.some(h=>h.payload===l&&h.type==="nack")&&r.push(u.mid),u.fmtp.some(h=>h.payload===l?(h.config.includes("sprop-stereo=1")&&n.push(u.mid),!0):!1))}),{stereoMids:n,nackMids:r}}function Yv(a){if(a.connection){const e=a.connection.ip.indexOf(":")>=0;(a.connection.version===4&&e||a.connection.version===6&&!e)&&(a.connection.ip="0.0.0.0",a.connection.version=4)}}const gf="vp8",y1={audioPreset:cf.music,dtx:!0,red:!0,forceStereo:!1,simulcast:!0,screenShareEncoding:Hf.h1080fps15.encoding,stopMicTrackOnMute:!1,videoCodec:gf,backupCodec:!0},Fy={deviceId:"default",autoGainControl:!0,echoCancellation:!0,noiseSuppression:!0,voiceIsolation:!0},Yy={deviceId:"default",resolution:Hs.h720.resolution},b1={adaptiveStream:!1,dynacast:!1,stopLocalTrackOnUnpublish:!0,reconnectPolicy:new uE,disconnectOnPageLeave:!0,webAudioMix:!1},Xf={autoSubscribe:!0,maxRetries:1,peerConnectionTimeout:15e3,websocketTimeout:15e3};var We;(function(a){a[a.NEW=0]="NEW",a[a.CONNECTING=1]="CONNECTING",a[a.CONNECTED=2]="CONNECTED",a[a.FAILED=3]="FAILED",a[a.CLOSING=4]="CLOSING",a[a.CLOSED=5]="CLOSED"})(We||(We={}));class S1{get needsPublisher(){return this.isPublisherConnectionRequired}get needsSubscriber(){return this.isSubscriberConnectionRequired}get currentState(){return this.state}constructor(e,n,r){var o;this.peerConnectionTimeout=Xf.peerConnectionTimeout,this.log=ke,this.updateState=()=>{var l;const u=this.state,d=this.requiredTransports.map(h=>h.getConnectionState());d.every(h=>h==="connected")?this.state=We.CONNECTED:d.some(h=>h==="failed")?this.state=We.FAILED:d.some(h=>h==="connecting")?this.state=We.CONNECTING:d.every(h=>h==="closed")?this.state=We.CLOSED:d.some(h=>h==="closed")?this.state=We.CLOSING:d.every(h=>h==="new")&&(this.state=We.NEW),u!==this.state&&(this.log.debug("pc state change: from ".concat(We[u]," to ").concat(We[this.state]),this.logContext),(l=this.onStateChange)===null||l===void 0||l.call(this,this.state,this.publisher.getConnectionState(),this.subscriber.getConnectionState()))},this.log=ei((o=r.loggerName)!==null&&o!==void 0?o:gn.PCManager),this.loggerOptions=r,this.isPublisherConnectionRequired=!n,this.isSubscriberConnectionRequired=n,this.publisher=new Gv(e,r),this.subscriber=new Gv(e,r),this.publisher.onConnectionStateChange=this.updateState,this.subscriber.onConnectionStateChange=this.updateState,this.publisher.onIceConnectionStateChange=this.updateState,this.subscriber.onIceConnectionStateChange=this.updateState,this.publisher.onSignalingStatechange=this.updateState,this.subscriber.onSignalingStatechange=this.updateState,this.publisher.onIceCandidate=l=>{var u;(u=this.onIceCandidate)===null||u===void 0||u.call(this,l,mn.PUBLISHER)},this.subscriber.onIceCandidate=l=>{var u;(u=this.onIceCandidate)===null||u===void 0||u.call(this,l,mn.SUBSCRIBER)},this.subscriber.onDataChannel=l=>{var u;(u=this.onDataChannel)===null||u===void 0||u.call(this,l)},this.subscriber.onTrack=l=>{var u;(u=this.onTrack)===null||u===void 0||u.call(this,l)},this.publisher.onOffer=l=>{var u;(u=this.onPublisherOffer)===null||u===void 0||u.call(this,l)},this.state=We.NEW,this.connectionLock=new Ht,this.remoteOfferLock=new Ht}get logContext(){var e,n;return Object.assign({},(n=(e=this.loggerOptions).loggerContextCb)===null||n===void 0?void 0:n.call(e))}requirePublisher(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.isPublisherConnectionRequired=e,this.updateState()}requireSubscriber(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.isSubscriberConnectionRequired=e,this.updateState()}createAndSendPublisherOffer(e){return this.publisher.createAndSendOffer(e)}setPublisherAnswer(e){return this.publisher.setRemoteDescription(e)}removeTrack(e){return this.publisher.removeTrack(e)}close(){return R(this,void 0,void 0,function*(){if(this.publisher&&this.publisher.getSignallingState()!=="closed"){const e=this.publisher;for(const n of e.getSenders())try{e.canRemoveTrack()&&e.removeTrack(n)}catch(r){this.log.warn("could not removeTrack",Object.assign(Object.assign({},this.logContext),{error:r}))}}yield Promise.all([this.publisher.close(),this.subscriber.close()]),this.updateState()})}triggerIceRestart(){return R(this,void 0,void 0,function*(){this.subscriber.restartingIce=!0,this.needsPublisher&&(yield this.createAndSendPublisherOffer({iceRestart:!0}))})}addIceCandidate(e,n){return R(this,void 0,void 0,function*(){n===mn.PUBLISHER?yield this.publisher.addIceCandidate(e):yield this.subscriber.addIceCandidate(e)})}createSubscriberAnswerFromOffer(e){return R(this,void 0,void 0,function*(){this.log.debug("received server offer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type,sdp:e.sdp,signalingState:this.subscriber.getSignallingState().toString()}));const n=yield this.remoteOfferLock.lock();try{return yield this.subscriber.setRemoteDescription(e),yield this.subscriber.createAndSetAnswer()}finally{n()}})}updateConfiguration(e,n){this.publisher.setConfiguration(e),this.subscriber.setConfiguration(e),n&&this.triggerIceRestart()}ensurePCTransportConnection(e,n){return R(this,void 0,void 0,function*(){var r;const o=yield this.connectionLock.lock();try{this.isPublisherConnectionRequired&&this.publisher.getConnectionState()!=="connected"&&this.publisher.getConnectionState()!=="connecting"&&(this.log.debug("negotiation required, start negotiating",this.logContext),this.publisher.negotiate()),yield Promise.all((r=this.requiredTransports)===null||r===void 0?void 0:r.map(l=>this.ensureTransportConnected(l,e,n)))}finally{o()}})}negotiate(e){return R(this,void 0,void 0,function*(){return new Promise((n,r)=>R(this,void 0,void 0,function*(){const o=setTimeout(()=>{r("negotiation timed out")},this.peerConnectionTimeout),l=()=>{clearTimeout(o),r("negotiation aborted")};e.signal.addEventListener("abort",l),this.publisher.once(mr.NegotiationStarted,()=>{e.signal.aborted||this.publisher.once(mr.NegotiationComplete,()=>{clearTimeout(o),n()})}),yield this.publisher.negotiate(u=>{clearTimeout(o),r(u)})}))})}addPublisherTransceiver(e,n){return this.publisher.addTransceiver(e,n)}addPublisherTrack(e){return this.publisher.addTrack(e)}createPublisherDataChannel(e,n){return this.publisher.createDataChannel(e,n)}getConnectedAddress(e){return e===mn.PUBLISHER?this.publisher.getConnectedAddress():e===mn.SUBSCRIBER?this.publisher.getConnectedAddress():this.requiredTransports[0].getConnectedAddress()}get requiredTransports(){const e=[];return this.isPublisherConnectionRequired&&e.push(this.publisher),this.isSubscriberConnectionRequired&&e.push(this.subscriber),e}ensureTransportConnected(e,n){return R(this,arguments,void 0,function(r,o){var l=this;let u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.peerConnectionTimeout;return function*(){if(r.getConnectionState()!=="connected")return new Promise((h,m)=>R(l,void 0,void 0,function*(){const g=()=>{this.log.warn("abort transport connection",this.logContext),Tt.clearTimeout(y),m(new Ie("room connection has been cancelled",Re.Cancelled))};o!=null&&o.signal.aborted&&g(),o==null||o.signal.addEventListener("abort",g);const y=Tt.setTimeout(()=>{o==null||o.signal.removeEventListener("abort",g),m(new Ie("could not establish pc connection",Re.InternalError))},u);for(;this.state!==We.CONNECTED;)if(yield Nt(50),o!=null&&o.signal.aborted){m(new Ie("room connection has been cancelled",Re.Cancelled));return}Tt.clearTimeout(y),o==null||o.signal.removeEventListener("abort",g),h()}))}()})}}class et extends Error{constructor(e,n,r){super(n),this.code=e,this.message=Kv(n,et.MAX_MESSAGE_BYTES),this.data=r?Kv(r,et.MAX_DATA_BYTES):void 0}static fromProto(e){return new et(e.code,e.message,e.data)}toProto(){return new H0({code:this.code,message:this.message,data:this.data})}static builtIn(e,n){return new et(et.ErrorCode[e],et.ErrorMessage[e],n)}}et.MAX_MESSAGE_BYTES=256;et.MAX_DATA_BYTES=15360;et.ErrorCode={APPLICATION_ERROR:1500,CONNECTION_TIMEOUT:1501,RESPONSE_TIMEOUT:1502,RECIPIENT_DISCONNECTED:1503,RESPONSE_PAYLOAD_TOO_LARGE:1504,SEND_FAILED:1505,UNSUPPORTED_METHOD:1400,RECIPIENT_NOT_FOUND:1401,REQUEST_PAYLOAD_TOO_LARGE:1402,UNSUPPORTED_SERVER:1403,UNSUPPORTED_VERSION:1404};et.ErrorMessage={APPLICATION_ERROR:"Application error in method handler",CONNECTION_TIMEOUT:"Connection timeout",RESPONSE_TIMEOUT:"Response timeout",RECIPIENT_DISCONNECTED:"Recipient disconnected",RESPONSE_PAYLOAD_TOO_LARGE:"Response payload too large",SEND_FAILED:"Failed to send",UNSUPPORTED_METHOD:"Method not supported at destination",RECIPIENT_NOT_FOUND:"Recipient not found",REQUEST_PAYLOAD_TOO_LARGE:"Request payload too large",UNSUPPORTED_SERVER:"RPC not supported by server",UNSUPPORTED_VERSION:"Unsupported RPC version"};const Ky=15360;function Zf(a){return new TextEncoder().encode(a).length}function Kv(a,e){if(Zf(a)<=e)return a;let n=0,r=a.length;const o=new TextEncoder;for(;n<r;){const l=Math.floor((n+r+1)/2);o.encode(a.slice(0,l)).length<=e?n=l:r=l-1}return a.slice(0,n)}const Jf=2e3;function Xc(a,e){if(!e)return 0;let n,r;return"bytesReceived"in a?(n=a.bytesReceived,r=e.bytesReceived):"bytesSent"in a&&(n=a.bytesSent,r=e.bytesSent),n===void 0||r===void 0||a.timestamp===void 0||e.timestamp===void 0?0:(n-r)*8*1e3/(a.timestamp-e.timestamp)}const T1=1e3;class Qy extends j{get sender(){return this._sender}set sender(e){this._sender=e}get constraints(){return this._constraints}constructor(e,n,r){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,l=arguments.length>4?arguments[4]:void 0;super(e,n,l),this.manuallyStopped=!1,this._isUpstreamPaused=!1,this.handleTrackMuteEvent=()=>this.debouncedTrackMuteHandler().catch(()=>this.log.debug("track mute bounce got cancelled by an unmute event",this.logContext)),this.debouncedTrackMuteHandler=Qf(()=>R(this,void 0,void 0,function*(){yield this.pauseUpstream()}),5e3),this.handleTrackUnmuteEvent=()=>R(this,void 0,void 0,function*(){this.debouncedTrackMuteHandler.cancel("unmute"),yield this.resumeUpstream()}),this.handleEnded=()=>{this.isInBackground&&(this.reacquireTrack=!0),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),this.emit(W.Ended,this)},this.reacquireTrack=!1,this.providedByUser=o,this.muteLock=new Ht,this.pauseUpstreamLock=new Ht,this.processorLock=new Ht,this.restartLock=new Ht,this.setMediaStreamTrack(e,!0),this._constraints=e.getConstraints(),r&&(this._constraints=r)}get id(){return this._mediaStreamTrack.id}get dimensions(){if(this.kind!==j.Kind.Video)return;const{width:e,height:n}=this._mediaStreamTrack.getSettings();if(e&&n)return{width:e,height:n}}get isUpstreamPaused(){return this._isUpstreamPaused}get isUserProvided(){return this.providedByUser}get mediaStreamTrack(){var e,n;return(n=(e=this.processor)===null||e===void 0?void 0:e.processedTrack)!==null&&n!==void 0?n:this._mediaStreamTrack}get isLocal(){return!0}getSourceTrackSettings(){return this._mediaStreamTrack.getSettings()}setMediaStreamTrack(e,n){return R(this,void 0,void 0,function*(){var r;if(e===this._mediaStreamTrack&&!n)return;this._mediaStreamTrack&&(this.attachedElements.forEach(l=>{fr(this._mediaStreamTrack,l)}),this.debouncedTrackMuteHandler.cancel("new-track"),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent)),this.mediaStream=new MediaStream([e]),e&&(e.addEventListener("ended",this.handleEnded),e.addEventListener("mute",this.handleTrackMuteEvent),e.addEventListener("unmute",this.handleTrackUnmuteEvent),this._constraints=e.getConstraints());let o;if(this.processor&&e){const l=yield this.processorLock.lock();try{if(this.log.debug("restarting processor",this.logContext),this.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");this.processorElement&&(lr(e,this.processorElement),this.processorElement.muted=!0),yield this.processor.restart({track:e,kind:this.kind,element:this.processorElement}),o=this.processor.processedTrack}finally{l()}}this.sender&&((r=this.sender.transport)===null||r===void 0?void 0:r.state)!=="closed"&&(yield this.sender.replaceTrack(o??e)),!this.providedByUser&&this._mediaStreamTrack!==e&&this._mediaStreamTrack.stop(),this._mediaStreamTrack=e,e&&(this._mediaStreamTrack.enabled=!this.isMuted,yield this.resumeUpstream(),this.attachedElements.forEach(l=>{lr(o??e,l)}))})}waitForDimensions(){return R(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:T1;return function*(){var r;if(e.kind===j.Kind.Audio)throw new Error("cannot get dimensions for audio tracks");((r=Dn())===null||r===void 0?void 0:r.os)==="iOS"&&(yield Nt(10));const o=Date.now();for(;Date.now()-o<n;){const l=e.dimensions;if(l)return l;yield Nt(50)}throw new $n("unable to get track dimensions after timeout")}()})}setDeviceId(e){return R(this,void 0,void 0,function*(){return this._constraints.deviceId===e&&this._mediaStreamTrack.getSettings().deviceId===Ii(e)||(this._constraints.deviceId=e,this.isMuted)?!0:(yield this.restartTrack(),Ii(e)===this._mediaStreamTrack.getSettings().deviceId)})}getDeviceId(){return R(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){if(e.source===j.Source.ScreenShare)return;const{deviceId:r,groupId:o}=e._mediaStreamTrack.getSettings(),l=e.kind===j.Kind.Audio?"audioinput":"videoinput";return n?gt.getInstance().normalizeDeviceId(l,r,o):r}()})}mute(){return R(this,void 0,void 0,function*(){return this.setTrackMuted(!0),this})}unmute(){return R(this,void 0,void 0,function*(){return this.setTrackMuted(!1),this})}replaceTrack(e,n){return R(this,void 0,void 0,function*(){if(!this.sender)throw new $n("unable to replace an unpublished track");let r,o;return typeof n=="boolean"?r=n:n!==void 0&&(r=n.userProvidedTrack,o=n.stopProcessor),this.providedByUser=r??!0,this.log.debug("replace MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(e),o&&this.processor&&(yield this.stopProcessor()),this})}restart(e){return R(this,void 0,void 0,function*(){this.manuallyStopped=!1;const n=yield this.restartLock.lock();try{e||(e=this._constraints);const{deviceId:r}=e,o=dE(e,["deviceId"]);this.log.debug("restarting track with constraints",Object.assign(Object.assign({},this.logContext),{constraints:e}));const l={audio:!1,video:!1};this.kind===j.Kind.Video?l.video=r?{deviceId:r}:!0:l.audio=r?{deviceId:r}:!0,this.attachedElements.forEach(h=>{fr(this.mediaStreamTrack,h)}),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.stop();const d=(yield navigator.mediaDevices.getUserMedia(l)).getTracks()[0];return yield d.applyConstraints(o),d.addEventListener("ended",this.handleEnded),this.log.debug("re-acquired MediaStreamTrack",this.logContext),yield this.setMediaStreamTrack(d),this._constraints=e,this.emit(W.Restarted,this),this.manuallyStopped&&(this.log.warn("track was stopped during a restart, stopping restarted track",this.logContext),this.stop()),this}finally{n()}})}setTrackMuted(e){this.log.debug("setting ".concat(this.kind," track ").concat(e?"muted":"unmuted"),this.logContext),!(this.isMuted===e&&this._mediaStreamTrack.enabled!==e)&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?W.Muted:W.Unmuted,this))}get needsReAcquisition(){return this._mediaStreamTrack.readyState!=="live"||this._mediaStreamTrack.muted||!this._mediaStreamTrack.enabled||this.reacquireTrack}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return R(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),By()&&(this.log.debug("visibility changed, is in Background: ".concat(this.isInBackground),this.logContext),!this.isInBackground&&this.needsReAcquisition&&!this.isUserProvided&&!this.isMuted&&(this.log.debug("track needs to be reacquired, restarting ".concat(this.source),this.logContext),yield this.restart(),this.reacquireTrack=!1))})}stop(){var e;this.manuallyStopped=!0,super.stop(),this._mediaStreamTrack.removeEventListener("ended",this.handleEnded),this._mediaStreamTrack.removeEventListener("mute",this.handleTrackMuteEvent),this._mediaStreamTrack.removeEventListener("unmute",this.handleTrackUnmuteEvent),(e=this.processor)===null||e===void 0||e.destroy(),this.processor=void 0}pauseUpstream(){return R(this,void 0,void 0,function*(){var e;const n=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!0)return;if(!this.sender){this.log.warn("unable to pause upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!0,this.emit(W.UpstreamPaused,this);const r=Dn();if((r==null?void 0:r.name)==="Safari"&&Sr(r.version,"12.0")<0)throw new Vf("pauseUpstream is not supported on Safari < 12.");((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(null))}finally{n()}})}resumeUpstream(){return R(this,void 0,void 0,function*(){var e;const n=yield this.pauseUpstreamLock.lock();try{if(this._isUpstreamPaused===!1)return;if(!this.sender){this.log.warn("unable to resume upstream for an unpublished track",this.logContext);return}this._isUpstreamPaused=!1,this.emit(W.UpstreamResumed,this),((e=this.sender.transport)===null||e===void 0?void 0:e.state)!=="closed"&&(yield this.sender.replaceTrack(this.mediaStreamTrack))}finally{n()}})}getRTCStatsReport(){return R(this,void 0,void 0,function*(){var e;return!((e=this.sender)===null||e===void 0)&&e.getStats?yield this.sender.getStats():void 0})}setProcessor(e){return R(this,arguments,void 0,function(n){var r=this;let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var l;const u=yield r.processorLock.lock();try{r.log.debug("setting up processor",r.logContext);const d=document.createElement(r.kind),h={kind:r.kind,track:r._mediaStreamTrack,element:d,audioContext:r.audioContext};if(yield n.init(h),r.log.debug("processor initialized",r.logContext),r.processor&&(yield r.stopProcessor()),r.kind==="unknown")throw TypeError("cannot set processor on track of unknown kind");if(lr(r._mediaStreamTrack,d),d.muted=!0,d.play().catch(m=>r.log.error("failed to play processor element",Object.assign(Object.assign({},r.logContext),{error:m}))),r.processor=n,r.processorElement=d,r.processor.processedTrack){for(const m of r.attachedElements)m!==r.processorElement&&o&&(fr(r._mediaStreamTrack,m),lr(r.processor.processedTrack,m));yield(l=r.sender)===null||l===void 0?void 0:l.replaceTrack(r.processor.processedTrack)}r.emit(W.TrackProcessorUpdate,r.processor)}finally{u()}}()})}getProcessor(){return this.processor}stopProcessor(){return R(this,arguments,void 0,function(){var e=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var r,o;e.processor&&(e.log.debug("stopping processor",e.logContext),(r=e.processor.processedTrack)===null||r===void 0||r.stop(),yield e.processor.destroy(),e.processor=void 0,n||((o=e.processorElement)===null||o===void 0||o.remove(),e.processorElement=void 0),yield e._mediaStreamTrack.applyConstraints(e._constraints),yield e.setMediaStreamTrack(e._mediaStreamTrack,!0),e.emit(W.TrackProcessorUpdate))}()})}}class Uc extends Qy{get enhancedNoiseCancellation(){return this.isKrispNoiseFilterEnabled}constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3?arguments[3]:void 0,l=arguments.length>4?arguments[4]:void 0;super(e,j.Kind.Audio,n,r,l),this.stopOnMute=!1,this.isKrispNoiseFilterEnabled=!1,this.monitorSender=()=>R(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let u;try{u=yield this.getSenderStats()}catch(d){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:d}));return}u&&this.prevStats&&(this._currentBitrate=Xc(u,this.prevStats)),this.prevStats=u}),this.handleKrispNoiseFilterEnable=()=>{this.isKrispNoiseFilterEnabled=!0,this.log.debug("Krisp noise filter enabled",this.logContext),this.emit(W.AudioTrackFeatureUpdate,this,On.TF_ENHANCED_NOISE_CANCELLATION,!0)},this.handleKrispNoiseFilterDisable=()=>{this.isKrispNoiseFilterEnabled=!1,this.log.debug("Krisp noise filter disabled",this.logContext),this.emit(W.AudioTrackFeatureUpdate,this,On.TF_ENHANCED_NOISE_CANCELLATION,!1)},this.audioContext=o,this.checkForSilence()}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return R(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===j.Source.Microphone&&this.stopOnMute&&!this.isUserProvided&&(this.log.debug("stopping mic track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{n()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return R(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{if(!this.isMuted)return this.log.debug("Track already unmuted",this.logContext),this;const r=this._constraints.deviceId&&this._mediaStreamTrack.getSettings().deviceId!==Ii(this._constraints.deviceId);return this.source===j.Source.Microphone&&(this.stopOnMute||this._mediaStreamTrack.readyState==="ended"||r)&&!this.isUserProvided&&(this.log.debug("reacquiring mic track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this}finally{n()}})}restartTrack(e){return R(this,void 0,void 0,function*(){let n;if(e){const r=Qc({audio:e});typeof r.audio!="boolean"&&(n=r.audio)}yield this.restart(n)})}restart(e){const n=Object.create(null,{restart:{get:()=>super.restart}});return R(this,void 0,void 0,function*(){const r=yield n.restart.call(this,e);return this.checkForSilence(),r})}startMonitor(){xt()&&(this.monitorInterval||(this.monitorInterval=setInterval(()=>{this.monitorSender()},Jf)))}setProcessor(e){return R(this,void 0,void 0,function*(){var n;const r=yield this.processorLock.lock();try{if(!An()&&!this.audioContext)throw Error("Audio context needs to be set on LocalAudioTrack in order to enable processors");this.processor&&(yield this.stopProcessor());const o={kind:this.kind,track:this._mediaStreamTrack,audioContext:this.audioContext};this.log.debug("setting up audio processor ".concat(e.name),this.logContext),yield e.init(o),this.processor=e,this.processor.processedTrack&&(yield(n=this.sender)===null||n===void 0?void 0:n.replaceTrack(this.processor.processedTrack),this.processor.processedTrack.addEventListener("enable-lk-krisp-noise-filter",this.handleKrispNoiseFilterEnable),this.processor.processedTrack.addEventListener("disable-lk-krisp-noise-filter",this.handleKrispNoiseFilterDisable)),this.emit(W.TrackProcessorUpdate,this.processor)}finally{r()}})}setAudioContext(e){this.audioContext=e}getSenderStats(){return R(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return;const n=yield this.sender.getStats();let r;return n.forEach(o=>{o.type==="outbound-rtp"&&(r={type:"audio",streamId:o.id,packetsSent:o.packetsSent,packetsLost:o.packetsLost,bytesSent:o.bytesSent,timestamp:o.timestamp,roundTripTime:o.roundTripTime,jitter:o.jitter})}),r})}checkForSilence(){return R(this,void 0,void 0,function*(){const e=yield Gy(this);return e&&(this.isMuted||this.log.warn("silence detected on local audio track",this.logContext),this.emit(W.AudioSilenceDetected)),e})}}function Xy(a,e,n){switch(a.kind){case"audio":return new Uc(a,e,!1,void 0,n);case"video":return new Lc(a,e,!1,n);default:throw new $n("unsupported track type: ".concat(a.kind))}}const k1=Object.values(Hs),C1=Object.values(lf),E1=Object.values(Hf),R1=[Hs.h180,Hs.h360],_1=[lf.h180,lf.h360],w1=a=>[{scaleResolutionDownBy:2,fps:a.encoding.maxFramerate}].map(n=>{var r,o;return new Ue(Math.floor(a.width/n.scaleResolutionDownBy),Math.floor(a.height/n.scaleResolutionDownBy),Math.max(15e4,Math.floor(a.encoding.maxBitrate/(Math.pow(n.scaleResolutionDownBy,2)*(((r=a.encoding.maxFramerate)!==null&&r!==void 0?r:30)/((o=n.fps)!==null&&o!==void 0?o:30))))),n.fps,a.encoding.priority)}),vf=["q","h","f"];function yf(a,e,n,r){var o,l;let u=r==null?void 0:r.videoEncoding;a&&(u=r==null?void 0:r.screenShareEncoding);const d=r==null?void 0:r.simulcast,h=r==null?void 0:r.scalabilityMode,m=r==null?void 0:r.videoCodec;if(!u&&!d&&!h||!e||!n)return[{}];u||(u=D1(a,e,n,m),ke.debug("using video encoding",u));const g=u.maxFramerate,y=new Ue(e,n,u.maxBitrate,u.maxFramerate,u.priority);if(h&&Is(m)){const C=new Zy(h),k=[];if(C.spatial>3)throw new Error("unsupported scalabilityMode: ".concat(h));const w=Dn();if(Bi()||An()||(w==null?void 0:w.name)==="Chrome"&&Sr(w==null?void 0:w.version,"113")<0){const O=C.suffix=="h"?2:3;for(let V=0;V<C.spatial;V+=1)k.push({rid:vf[2-V],maxBitrate:u.maxBitrate/Math.pow(O,V),maxFramerate:y.encoding.maxFramerate});k[0].scalabilityMode=h}else k.push({maxBitrate:u.maxBitrate,maxFramerate:y.encoding.maxFramerate,scalabilityMode:h});return y.encoding.priority&&(k[0].priority=y.encoding.priority,k[0].networkPriority=y.encoding.priority),ke.debug("using svc encoding",{encodings:k}),k}if(!d)return[u];let b=[];a?b=(o=Xv(r==null?void 0:r.screenShareSimulcastLayers))!==null&&o!==void 0?o:Qv(a,y):b=(l=Xv(r==null?void 0:r.videoSimulcastLayers))!==null&&l!==void 0?l:Qv(a,y);let T;if(b.length>0){const C=b[0];b.length>1&&([,T]=b);const k=Math.max(e,n);if(k>=960&&T)return Ud(e,n,[C,T,y],g);if(k>=480)return Ud(e,n,[C,y],g)}return Ud(e,n,[y])}function O1(a,e,n){var r,o,l,u;if(!n.backupCodec||n.backupCodec===!0||n.backupCodec.codec===n.videoCodec)return;e!==n.backupCodec.codec&&ke.warn("requested a different codec than specified as backup",{serverRequested:e,backup:n.backupCodec.codec}),n.videoCodec=e,n.videoEncoding=n.backupCodec.encoding;const d=a.mediaStreamTrack.getSettings(),h=(r=d.width)!==null&&r!==void 0?r:(o=a.dimensions)===null||o===void 0?void 0:o.width,m=(l=d.height)!==null&&l!==void 0?l:(u=a.dimensions)===null||u===void 0?void 0:u.height;return a.source===j.Source.ScreenShare&&n.simulcast&&(n.simulcast=!1),yf(a.source===j.Source.ScreenShare,h,m,n)}function D1(a,e,n,r){const o=A1(a,e,n);let{encoding:l}=o[0];const u=Math.max(e,n);for(let d=0;d<o.length;d+=1){const h=o[d];if(l=h.encoding,h.width>=u)break}if(r)switch(r){case"av1":l=Object.assign({},l),l.maxBitrate=l.maxBitrate*.7;break;case"vp9":l=Object.assign({},l),l.maxBitrate=l.maxBitrate*.85;break}return l}function A1(a,e,n){if(a)return E1;const r=e>n?e/n:n/e;return Math.abs(r-16/9)<Math.abs(r-4/3)?k1:C1}function Qv(a,e){if(a)return w1(e);const{width:n,height:r}=e,o=n>r?n/r:r/n;return Math.abs(o-16/9)<Math.abs(o-4/3)?R1:_1}function Ud(a,e,n,r){const o=[];if(n.forEach((l,u)=>{if(u>=vf.length)return;const d=Math.min(a,e),m={rid:vf[u],scaleResolutionDownBy:Math.max(1,d/Math.min(l.width,l.height)),maxBitrate:l.encoding.maxBitrate},g=r&&l.encoding.maxFramerate?Math.min(r,l.encoding.maxFramerate):l.encoding.maxFramerate;g&&(m.maxFramerate=g);const y=br()||u===0;l.encoding.priority&&y&&(m.priority=l.encoding.priority,m.networkPriority=l.encoding.priority),o.push(m)}),An()&&qy()==="ios"){let l;o.forEach(d=>{l?d.maxFramerate&&d.maxFramerate>l&&(l=d.maxFramerate):l=d.maxFramerate});let u=!0;o.forEach(d=>{var h;d.maxFramerate!=l&&(u&&(u=!1,ke.info("Simulcast on iOS React-Native requires all encodings to share the same framerate.")),ke.info('Setting framerate of encoding "'.concat((h=d.rid)!==null&&h!==void 0?h:"",'" to ').concat(l)),d.maxFramerate=l)})}return o}function Xv(a){if(a)return a.sort((e,n)=>{const{encoding:r}=e,{encoding:o}=n;return r.maxBitrate>o.maxBitrate?1:r.maxBitrate<o.maxBitrate?-1:r.maxBitrate===o.maxBitrate&&r.maxFramerate&&o.maxFramerate?r.maxFramerate>o.maxFramerate?1:-1:0})}class Zy{constructor(e){const n=e.match(/^L(\d)T(\d)(h|_KEY|_KEY_SHIFT){0,1}$/);if(!n)throw new Error("invalid scalability mode");if(this.spatial=parseInt(n[1]),this.temporal=parseInt(n[2]),n.length>3)switch(n[3]){case"h":case"_KEY":case"_KEY_SHIFT":this.suffix=n[3]}}toString(){var e;return"L".concat(this.spatial,"T").concat(this.temporal).concat((e=this.suffix)!==null&&e!==void 0?e:"")}}function M1(a){return a.source===j.Source.ScreenShare||a.constraints.height&&Ii(a.constraints.height)>=1080?"maintain-resolution":"balanced"}const P1=5e3;class Lc extends Qy{get sender(){return this._sender}set sender(e){this._sender=e,this.degradationPreference&&this.setDegradationPreference(this.degradationPreference)}constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=arguments.length>3?arguments[3]:void 0;super(e,j.Kind.Video,n,r,o),this.simulcastCodecs=new Map,this.degradationPreference="balanced",this.monitorSender=()=>R(this,void 0,void 0,function*(){if(!this.sender){this._currentBitrate=0;return}let l;try{l=yield this.getSenderStats()}catch(d){this.log.error("could not get audio sender stats",Object.assign(Object.assign({},this.logContext),{error:d}));return}const u=new Map(l.map(d=>[d.rid,d]));if(this.prevStats){let d=0;u.forEach((h,m)=>{var g;const y=(g=this.prevStats)===null||g===void 0?void 0:g.get(m);d+=Xc(h,y)}),this._currentBitrate=d}this.prevStats=u}),this.senderLock=new Ht}get isSimulcast(){return!!(this.sender&&this.sender.getParameters().encodings.length>1)}startMonitor(e){var n;if(this.signalClient=e,!xt())return;const r=(n=this.sender)===null||n===void 0?void 0:n.getParameters();r&&(this.encodings=r.encodings),!this.monitorInterval&&(this.monitorInterval=setInterval(()=>{this.monitorSender()},Jf))}stop(){this._mediaStreamTrack.getConstraints(),this.simulcastCodecs.forEach(e=>{e.mediaStreamTrack.stop()}),super.stop()}pauseUpstream(){const e=Object.create(null,{pauseUpstream:{get:()=>super.pauseUpstream}});return R(this,void 0,void 0,function*(){var n,r,o,l,u;yield e.pauseUpstream.call(this);try{for(var d=!0,h=xi(this.simulcastCodecs.values()),m;m=yield h.next(),n=m.done,!n;d=!0)l=m.value,d=!1,yield(u=l.sender)===null||u===void 0?void 0:u.replaceTrack(null)}catch(g){r={error:g}}finally{try{!d&&!n&&(o=h.return)&&(yield o.call(h))}finally{if(r)throw r.error}}})}resumeUpstream(){const e=Object.create(null,{resumeUpstream:{get:()=>super.resumeUpstream}});return R(this,void 0,void 0,function*(){var n,r,o,l,u;yield e.resumeUpstream.call(this);try{for(var d=!0,h=xi(this.simulcastCodecs.values()),m;m=yield h.next(),n=m.done,!n;d=!0){l=m.value,d=!1;const g=l;yield(u=g.sender)===null||u===void 0?void 0:u.replaceTrack(g.mediaStreamTrack)}}catch(g){r={error:g}}finally{try{!d&&!n&&(o=h.return)&&(yield o.call(h))}finally{if(r)throw r.error}}})}mute(){const e=Object.create(null,{mute:{get:()=>super.mute}});return R(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.log.debug("Track already muted",this.logContext),this):(this.source===j.Source.Camera&&!this.isUserProvided&&(this.log.debug("stopping camera track",this.logContext),this._mediaStreamTrack.stop()),yield e.mute.call(this),this)}finally{n()}})}unmute(){const e=Object.create(null,{unmute:{get:()=>super.unmute}});return R(this,void 0,void 0,function*(){const n=yield this.muteLock.lock();try{return this.isMuted?(this.source===j.Source.Camera&&!this.isUserProvided&&(this.log.debug("reacquiring camera track",this.logContext),yield this.restartTrack()),yield e.unmute.call(this),this):(this.log.debug("Track already unmuted",this.logContext),this)}finally{n()}})}setTrackMuted(e){super.setTrackMuted(e);for(const n of this.simulcastCodecs.values())n.mediaStreamTrack.enabled=!e}getSenderStats(){return R(this,void 0,void 0,function*(){var e;if(!(!((e=this.sender)===null||e===void 0)&&e.getStats))return[];const n=[],r=yield this.sender.getStats();return r.forEach(o=>{var l;if(o.type==="outbound-rtp"){const u={type:"video",streamId:o.id,frameHeight:o.frameHeight,frameWidth:o.frameWidth,framesPerSecond:o.framesPerSecond,framesSent:o.framesSent,firCount:o.firCount,pliCount:o.pliCount,nackCount:o.nackCount,packetsSent:o.packetsSent,bytesSent:o.bytesSent,qualityLimitationReason:o.qualityLimitationReason,qualityLimitationDurations:o.qualityLimitationDurations,qualityLimitationResolutionChanges:o.qualityLimitationResolutionChanges,rid:(l=o.rid)!==null&&l!==void 0?l:o.id,retransmittedPacketsSent:o.retransmittedPacketsSent,targetBitrate:o.targetBitrate,timestamp:o.timestamp},d=r.get(o.remoteId);d&&(u.jitter=d.jitter,u.packetsLost=d.packetsLost,u.roundTripTime=d.roundTripTime),n.push(u)}}),n.sort((o,l)=>{var u,d;return((u=l.frameWidth)!==null&&u!==void 0?u:0)-((d=o.frameWidth)!==null&&d!==void 0?d:0)}),n})}setPublishingQuality(e){const n=[];for(let r=rn.LOW;r<=rn.HIGH;r+=1)n.push(new Bf({quality:r,enabled:r<=e}));this.log.debug("setting publishing quality. max quality ".concat(e),this.logContext),this.setPublishingLayers(n)}restartTrack(e){return R(this,void 0,void 0,function*(){var n,r,o,l,u;let d;if(e){const y=Qc({video:e});typeof y.video!="boolean"&&(d=y.video)}yield this.restart(d);try{for(var h=!0,m=xi(this.simulcastCodecs.values()),g;g=yield m.next(),n=g.done,!n;h=!0){l=g.value,h=!1;const y=l;y.sender&&((u=y.sender.transport)===null||u===void 0?void 0:u.state)!=="closed"&&(y.mediaStreamTrack=this.mediaStreamTrack.clone(),yield y.sender.replaceTrack(y.mediaStreamTrack))}}catch(y){r={error:y}}finally{try{!h&&!n&&(o=m.return)&&(yield o.call(m))}finally{if(r)throw r.error}}})}setProcessor(e){const n=Object.create(null,{setProcessor:{get:()=>super.setProcessor}});return R(this,arguments,void 0,function(r){var o=this;let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){var u,d,h,m,g,y;if(yield n.setProcessor.call(o,r,l),!((g=o.processor)===null||g===void 0)&&g.processedTrack)try{for(var b=!0,T=xi(o.simulcastCodecs.values()),C;C=yield T.next(),u=C.done,!u;b=!0)m=C.value,b=!1,yield(y=m.sender)===null||y===void 0?void 0:y.replaceTrack(o.processor.processedTrack)}catch(k){d={error:k}}finally{try{!b&&!u&&(h=T.return)&&(yield h.call(T))}finally{if(d)throw d.error}}}()})}setDegradationPreference(e){return R(this,void 0,void 0,function*(){if(this.degradationPreference=e,this.sender)try{this.log.debug("setting degradationPreference to ".concat(e),this.logContext);const n=this.sender.getParameters();n.degradationPreference=e,this.sender.setParameters(n)}catch(n){this.log.warn("failed to set degradationPreference",Object.assign({error:n},this.logContext))}})}addSimulcastTrack(e,n){if(this.simulcastCodecs.has(e)){this.log.error("".concat(e," already added, skipping adding simulcast codec"),this.logContext);return}const r={codec:e,mediaStreamTrack:this.mediaStreamTrack.clone(),sender:void 0,encodings:n};return this.simulcastCodecs.set(e,r),r}setSimulcastTrackSender(e,n){const r=this.simulcastCodecs.get(e);r&&(r.sender=n,setTimeout(()=>{this.subscribedCodecs&&this.setPublishingCodecs(this.subscribedCodecs)},P1))}setPublishingCodecs(e){return R(this,void 0,void 0,function*(){var n,r,o,l,u,d,h;if(this.log.debug("setting publishing codecs",Object.assign(Object.assign({},this.logContext),{codecs:e,currentCodec:this.codec})),!this.codec&&e.length>0)return yield this.setPublishingLayers(e[0].qualities),[];this.subscribedCodecs=e;const m=[];try{for(n=!0,r=xi(e);o=yield r.next(),l=o.done,!l;n=!0){h=o.value,n=!1;const g=h;if(!this.codec||this.codec===g.codec)yield this.setPublishingLayers(g.qualities);else{const y=this.simulcastCodecs.get(g.codec);if(this.log.debug("try setPublishingCodec for ".concat(g.codec),Object.assign(Object.assign({},this.logContext),{simulcastCodecInfo:y})),!y||!y.sender){for(const b of g.qualities)if(b.enabled){m.push(g.codec);break}}else y.encodings&&(this.log.debug("try setPublishingLayersForSender ".concat(g.codec),this.logContext),yield Zv(y.sender,y.encodings,g.qualities,this.senderLock,this.log,this.logContext))}}}catch(g){u={error:g}}finally{try{!n&&!l&&(d=r.return)&&(yield d.call(r))}finally{if(u)throw u.error}}return m})}setPublishingLayers(e){return R(this,void 0,void 0,function*(){this.log.debug("setting publishing layers",Object.assign(Object.assign({},this.logContext),{qualities:e})),!(!this.sender||!this.encodings)&&(yield Zv(this.sender,this.encodings,e,this.senderLock,this.log,this.logContext))})}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return R(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),By()&&this.isInBackground&&this.source===j.Source.Camera&&(this._mediaStreamTrack.enabled=!1)})}}function Zv(a,e,n,r,o,l){return R(this,void 0,void 0,function*(){const u=yield r.lock();o.debug("setPublishingLayersForSender",Object.assign(Object.assign({},l),{sender:a,qualities:n,senderEncodings:e}));try{const d=a.getParameters(),{encodings:h}=d;if(!h)return;if(h.length!==e.length){o.warn("cannot set publishing layers, encodings mismatch",Object.assign(Object.assign({},l),{encodings:h,senderEncodings:e}));return}let m=!1;!1&&h[0].scalabilityMode||h.forEach((y,b)=>{var T;let C=(T=y.rid)!==null&&T!==void 0?T:"";C===""&&(C="q");const k=Jy(C),w=n.find(O=>O.quality===k);w&&y.active!==w.enabled&&(m=!0,y.active=w.enabled,o.debug("setting layer ".concat(w.quality," to ").concat(y.active?"enabled":"disabled"),l),br()&&(w.enabled?(y.scaleResolutionDownBy=e[b].scaleResolutionDownBy,y.maxBitrate=e[b].maxBitrate,y.maxFrameRate=e[b].maxFrameRate):(y.scaleResolutionDownBy=4,y.maxBitrate=10,y.maxFrameRate=2)))}),m&&(d.encodings=h,o.debug("setting encodings",Object.assign(Object.assign({},l),{encodings:d.encodings})),yield a.setParameters(d))}finally{u()}})}function Jy(a){switch(a){case"f":return rn.HIGH;case"h":return rn.MEDIUM;case"q":return rn.LOW;default:return rn.HIGH}}function Jv(a,e,n,r){if(!n)return[new pa({quality:rn.HIGH,width:a,height:e,bitrate:0,ssrc:0})];if(r){const o=n[0].scalabilityMode,l=new Zy(o),u=[],d=l.suffix=="h"?1.5:2,h=l.suffix=="h"?2:3;for(let m=0;m<l.spatial;m+=1)u.push(new pa({quality:Math.min(rn.HIGH,l.spatial-1)-m,width:Math.ceil(a/Math.pow(d,m)),height:Math.ceil(e/Math.pow(d,m)),bitrate:n[0].maxBitrate?Math.ceil(n[0].maxBitrate/Math.pow(h,m)):0,ssrc:0}));return u}return n.map(o=>{var l,u,d;const h=(l=o.scaleResolutionDownBy)!==null&&l!==void 0?l:1;let m=Jy((u=o.rid)!==null&&u!==void 0?u:"");return new pa({quality:m,width:Math.ceil(a/h),height:Math.ceil(e/h),bitrate:(d=o.maxBitrate)!==null&&d!==void 0?d:0,ssrc:0})})}const Wv="_lossy",$v="_reliable",x1=2*1e3,Ld="leave-reconnect";var dn;(function(a){a[a.New=0]="New",a[a.Connected=1]="Connected",a[a.Disconnected=2]="Disconnected",a[a.Reconnecting=3]="Reconnecting",a[a.Closed=4]="Closed"})(dn||(dn={}));class N1 extends xn.EventEmitter{get isClosed(){return this._isClosed}get pendingReconnect(){return!!this.reconnectTimeout}constructor(e){var n;super(),this.options=e,this.rtcConfig={},this.peerConnectionTimeout=Xf.peerConnectionTimeout,this.fullReconnectOnNext=!1,this.subscriberPrimary=!1,this.pcState=dn.New,this._isClosed=!0,this.pendingTrackResolvers={},this.reconnectAttempts=0,this.reconnectStart=0,this.attemptingReconnect=!1,this.joinAttempts=0,this.maxJoinAttempts=1,this.shouldFailNext=!1,this.log=ke,this.handleDataChannel=r=>R(this,[r],void 0,function(o){var l=this;let{channel:u}=o;return function*(){if(u){if(u.label===$v)l.reliableDCSub=u;else if(u.label===Wv)l.lossyDCSub=u;else return;l.log.debug("on data channel ".concat(u.id,", ").concat(u.label),l.logContext),u.onmessage=l.handleDataMessage}}()}),this.handleDataMessage=r=>R(this,void 0,void 0,function*(){var o,l;const u=yield this.dataProcessLock.lock();try{let d;if(r.data instanceof ArrayBuffer)d=r.data;else if(r.data instanceof Blob)d=yield r.data.arrayBuffer();else{this.log.error("unsupported data type",Object.assign(Object.assign({},this.logContext),{data:r.data}));return}const h=Mt.fromBinary(new Uint8Array(d));((o=h.value)===null||o===void 0?void 0:o.case)==="speaker"?this.emit(ne.ActiveSpeakersUpdate,h.value.value.speakers):(((l=h.value)===null||l===void 0?void 0:l.case)==="user"&&L1(h,h.value.value),this.emit(ne.DataPacketReceived,h))}finally{u()}}),this.handleDataError=r=>{const l=r.currentTarget.maxRetransmits===0?"lossy":"reliable";if(r instanceof ErrorEvent&&r.error){const{error:u}=r.error;this.log.error("DataChannel error on ".concat(l,": ").concat(r.message),Object.assign(Object.assign({},this.logContext),{error:u}))}else this.log.error("Unknown DataChannel error on ".concat(l),Object.assign(Object.assign({},this.logContext),{event:r}))},this.handleBufferedAmountLow=r=>{const l=r.currentTarget.maxRetransmits===0?_e.LOSSY:_e.RELIABLE;this.updateAndEmitDCBufferStatus(l)},this.handleDisconnect=(r,o)=>{if(this._isClosed)return;this.log.warn("".concat(r," disconnected"),this.logContext),this.reconnectAttempts===0&&(this.reconnectStart=Date.now());const l=h=>{this.log.warn("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(h,"ms. giving up"),this.logContext),this.emit(ne.Disconnected),this.close()},u=Date.now()-this.reconnectStart;let d=this.getNextRetryDelay({elapsedMs:u,retryCount:this.reconnectAttempts});if(d===null){l(u);return}r===Ld&&(d=0),this.log.debug("reconnecting in ".concat(d,"ms"),this.logContext),this.clearReconnectTimeout(),this.token&&this.regionUrlProvider&&this.regionUrlProvider.updateToken(this.token),this.reconnectTimeout=Tt.setTimeout(()=>this.attemptReconnect(o).finally(()=>this.reconnectTimeout=void 0),d)},this.waitForRestarted=()=>new Promise((r,o)=>{this.pcState===dn.Connected&&r();const l=()=>{this.off(ne.Disconnected,u),r()},u=()=>{this.off(ne.Restarted,l),o()};this.once(ne.Restarted,l),this.once(ne.Disconnected,u)}),this.updateAndEmitDCBufferStatus=r=>{const o=this.isBufferStatusLow(r);typeof o<"u"&&o!==this.dcBufferStatus.get(r)&&(this.dcBufferStatus.set(r,o),this.emit(ne.DCBufferStatusChanged,o,r))},this.isBufferStatusLow=r=>{const o=this.dataChannelForKind(r);if(o)return o.bufferedAmount<=o.bufferedAmountLowThreshold},this.handleBrowserOnLine=()=>{this.client.currentState===He.RECONNECTING&&(this.clearReconnectTimeout(),this.attemptReconnect(sr.RR_SIGNAL_DISCONNECTED))},this.log=ei((n=e.loggerName)!==null&&n!==void 0?n:gn.Engine),this.loggerOptions={loggerName:e.loggerName,loggerContextCb:()=>this.logContext},this.client=new Yf(void 0,this.loggerOptions),this.client.signalLatency=this.options.expSignalLatency,this.reconnectPolicy=this.options.reconnectPolicy,this.registerOnLineListener(),this.closingLock=new Ht,this.dataProcessLock=new Ht,this.dcBufferStatus=new Map([[_e.LOSSY,!0],[_e.RELIABLE,!0]]),this.client.onParticipantUpdate=r=>this.emit(ne.ParticipantUpdate,r),this.client.onConnectionQuality=r=>this.emit(ne.ConnectionQualityUpdate,r),this.client.onRoomUpdate=r=>this.emit(ne.RoomUpdate,r),this.client.onSubscriptionError=r=>this.emit(ne.SubscriptionError,r),this.client.onSubscriptionPermissionUpdate=r=>this.emit(ne.SubscriptionPermissionUpdate,r),this.client.onSpeakersChanged=r=>this.emit(ne.SpeakersChanged,r),this.client.onStreamStateUpdate=r=>this.emit(ne.StreamStateChanged,r),this.client.onRequestResponse=r=>this.emit(ne.SignalRequestResponse,r)}get logContext(){var e,n,r,o,l,u,d,h;return{room:(n=(e=this.latestJoinResponse)===null||e===void 0?void 0:e.room)===null||n===void 0?void 0:n.name,roomID:(o=(r=this.latestJoinResponse)===null||r===void 0?void 0:r.room)===null||o===void 0?void 0:o.sid,participant:(u=(l=this.latestJoinResponse)===null||l===void 0?void 0:l.participant)===null||u===void 0?void 0:u.identity,pID:(h=(d=this.latestJoinResponse)===null||d===void 0?void 0:d.participant)===null||h===void 0?void 0:h.sid}}join(e,n,r,o){return R(this,void 0,void 0,function*(){this.url=e,this.token=n,this.signalOpts=r,this.maxJoinAttempts=r.maxRetries;try{this.joinAttempts+=1,this.setupSignalClientCallbacks();const l=yield this.client.join(e,n,r,o);return this._isClosed=!1,this.latestJoinResponse=l,this.subscriberPrimary=l.subscriberPrimary,this.pcManager||(yield this.configure(l)),(!this.subscriberPrimary||l.fastPublish)&&this.negotiate(),this.clientConfiguration=l.clientConfiguration,l}catch(l){if(l instanceof Ie&&l.reason===Re.ServerUnreachable&&(this.log.warn("Couldn't connect to server, attempt ".concat(this.joinAttempts," of ").concat(this.maxJoinAttempts),this.logContext),this.joinAttempts<this.maxJoinAttempts))return this.join(e,n,r,o);throw l}})}close(){return R(this,void 0,void 0,function*(){const e=yield this.closingLock.lock();if(this.isClosed){e();return}try{this._isClosed=!0,this.joinAttempts=0,this.emit(ne.Closing),this.removeAllListeners(),this.deregisterOnLineListener(),this.clearPendingReconnect(),yield this.cleanupPeerConnections(),yield this.cleanupClient()}finally{e()}})}cleanupPeerConnections(){return R(this,void 0,void 0,function*(){var e;yield(e=this.pcManager)===null||e===void 0?void 0:e.close(),this.pcManager=void 0;const n=r=>{r&&(r.close(),r.onbufferedamountlow=null,r.onclose=null,r.onclosing=null,r.onerror=null,r.onmessage=null,r.onopen=null)};n(this.lossyDC),n(this.lossyDCSub),n(this.reliableDC),n(this.reliableDCSub),this.lossyDC=void 0,this.lossyDCSub=void 0,this.reliableDC=void 0,this.reliableDCSub=void 0})}cleanupClient(){return R(this,void 0,void 0,function*(){yield this.client.close(),this.client.resetCallbacks()})}addTrack(e){if(this.pendingTrackResolvers[e.cid])throw new $n("a track with the same ID has already been published");return new Promise((n,r)=>{const o=setTimeout(()=>{delete this.pendingTrackResolvers[e.cid],r(new Ie("publication of local track timed out, no response from server",Re.InternalError))},1e4);this.pendingTrackResolvers[e.cid]={resolve:l=>{clearTimeout(o),n(l)},reject:()=>{clearTimeout(o),r(new Error("Cancelled publication by calling unpublish"))}},this.client.sendAddTrack(e)})}removeTrack(e){if(e.track&&this.pendingTrackResolvers[e.track.id]){const{reject:n}=this.pendingTrackResolvers[e.track.id];n&&n(),delete this.pendingTrackResolvers[e.track.id]}try{return this.pcManager.removeTrack(e),!0}catch(n){this.log.warn("failed to remove track",Object.assign(Object.assign({},this.logContext),{error:n}))}return!1}updateMuteStatus(e,n){this.client.sendMuteTrack(e,n)}get dataSubscriberReadyState(){var e;return(e=this.reliableDCSub)===null||e===void 0?void 0:e.readyState}getConnectedServerAddress(){return R(this,void 0,void 0,function*(){var e;return(e=this.pcManager)===null||e===void 0?void 0:e.getConnectedAddress()})}setRegionUrlProvider(e){this.regionUrlProvider=e}configure(e){return R(this,void 0,void 0,function*(){var n,r;if(this.pcManager&&this.pcManager.currentState!==We.NEW)return;this.participantSid=(n=e.participant)===null||n===void 0?void 0:n.sid;const o=this.makeRTCConfiguration(e);this.pcManager=new S1(o,e.subscriberPrimary,this.loggerOptions),this.emit(ne.TransportsCreated,this.pcManager.publisher,this.pcManager.subscriber),this.pcManager.onIceCandidate=(l,u)=>{this.client.sendIceCandidate(l,u)},this.pcManager.onPublisherOffer=l=>{this.client.sendOffer(l)},this.pcManager.onDataChannel=this.handleDataChannel,this.pcManager.onStateChange=(l,u,d)=>R(this,void 0,void 0,function*(){if(this.log.debug("primary PC state changed ".concat(l),this.logContext),["closed","disconnected","failed"].includes(u)&&(this.publisherConnectionPromise=void 0),l===We.CONNECTED){const g=this.pcState===dn.New;this.pcState=dn.Connected,g&&this.emit(ne.Connected,e)}else l===We.FAILED&&this.pcState===dn.Connected&&(this.pcState=dn.Disconnected,this.handleDisconnect("peerconnection failed",d==="failed"?sr.RR_SUBSCRIBER_FAILED:sr.RR_PUBLISHER_FAILED));const h=this.client.isDisconnected||this.client.currentState===He.RECONNECTING,m=[We.FAILED,We.CLOSING,We.CLOSED].includes(l);h&&m&&!this._isClosed&&this.emit(ne.Offline)}),this.pcManager.onTrack=l=>{this.emit(ne.MediaTrackAdded,l.track,l.streams[0],l.receiver)},U1((r=e.serverInfo)===null||r===void 0?void 0:r.protocol)||this.createDataChannels()})}setupSignalClientCallbacks(){this.client.onAnswer=e=>R(this,void 0,void 0,function*(){this.pcManager&&(this.log.debug("received server answer",Object.assign(Object.assign({},this.logContext),{RTCSdpType:e.type})),yield this.pcManager.setPublisherAnswer(e))}),this.client.onTrickle=(e,n)=>{this.pcManager&&(this.log.debug("got ICE candidate from peer",Object.assign(Object.assign({},this.logContext),{candidate:e,target:n})),this.pcManager.addIceCandidate(e,n))},this.client.onOffer=e=>R(this,void 0,void 0,function*(){if(!this.pcManager)return;const n=yield this.pcManager.createSubscriberAnswerFromOffer(e);this.client.sendAnswer(n)}),this.client.onLocalTrackPublished=e=>{var n;if(this.log.debug("received trackPublishedResponse",Object.assign(Object.assign({},this.logContext),{cid:e.cid,track:(n=e.track)===null||n===void 0?void 0:n.sid})),!this.pendingTrackResolvers[e.cid]){this.log.error("missing track resolver for ".concat(e.cid),Object.assign(Object.assign({},this.logContext),{cid:e.cid}));return}const{resolve:r}=this.pendingTrackResolvers[e.cid];delete this.pendingTrackResolvers[e.cid],r(e.track)},this.client.onLocalTrackUnpublished=e=>{this.emit(ne.LocalTrackUnpublished,e)},this.client.onLocalTrackSubscribed=e=>{this.emit(ne.LocalTrackSubscribed,e)},this.client.onTokenRefresh=e=>{this.token=e},this.client.onRemoteMuteChanged=(e,n)=>{this.emit(ne.RemoteMute,e,n)},this.client.onSubscribedQualityUpdate=e=>{this.emit(ne.SubscribedQualityUpdate,e)},this.client.onClose=()=>{this.handleDisconnect("signal",sr.RR_SIGNAL_DISCONNECTED)},this.client.onLeave=e=>{switch(this.log.debug("client leave request",Object.assign(Object.assign({},this.logContext),{reason:e==null?void 0:e.reason})),e.regions&&this.regionUrlProvider&&(this.log.debug("updating regions",this.logContext),this.regionUrlProvider.setServerReportedRegions(e.regions)),e.action){case ur.DISCONNECT:this.emit(ne.Disconnected,e==null?void 0:e.reason),this.close();break;case ur.RECONNECT:this.fullReconnectOnNext=!0,this.handleDisconnect(Ld);break;case ur.RESUME:this.handleDisconnect(Ld)}}}makeRTCConfiguration(e){var n;const r=Object.assign({},this.rtcConfig);if(!((n=this.signalOpts)===null||n===void 0)&&n.e2eeEnabled&&(this.log.debug("E2EE - setting up transports with insertable streams",this.logContext),r.encodedInsertableStreams=!0),e.iceServers&&!r.iceServers){const o=[];e.iceServers.forEach(l=>{const u={urls:l.urls};l.username&&(u.username=l.username),l.credential&&(u.credential=l.credential),o.push(u)}),r.iceServers=o}return e.clientConfiguration&&e.clientConfiguration.forceRelay===Bs.ENABLED&&(r.iceTransportPolicy="relay"),r.sdpSemantics="unified-plan",r.continualGatheringPolicy="gather_continually",r}createDataChannels(){this.pcManager&&(this.lossyDC&&(this.lossyDC.onmessage=null,this.lossyDC.onerror=null),this.reliableDC&&(this.reliableDC.onmessage=null,this.reliableDC.onerror=null),this.lossyDC=this.pcManager.createPublisherDataChannel(Wv,{ordered:!0,maxRetransmits:0}),this.reliableDC=this.pcManager.createPublisherDataChannel($v,{ordered:!0}),this.lossyDC.onmessage=this.handleDataMessage,this.reliableDC.onmessage=this.handleDataMessage,this.lossyDC.onerror=this.handleDataError,this.reliableDC.onerror=this.handleDataError,this.lossyDC.bufferedAmountLowThreshold=65535,this.reliableDC.bufferedAmountLowThreshold=65535,this.lossyDC.onbufferedamountlow=this.handleBufferedAmountLow,this.reliableDC.onbufferedamountlow=this.handleBufferedAmountLow)}createSender(e,n,r){return R(this,void 0,void 0,function*(){if(uf())return yield this.createTransceiverRTCRtpSender(e,n,r);if(df())return this.log.warn("using add-track fallback",this.logContext),yield this.createRTCRtpSender(e.mediaStreamTrack);throw new ut("Required webRTC APIs not supported on this device")})}createSimulcastSender(e,n,r,o){return R(this,void 0,void 0,function*(){if(uf())return this.createSimulcastTransceiverSender(e,n,r,o);if(df())return this.log.debug("using add-track fallback",this.logContext),this.createRTCRtpSender(e.mediaStreamTrack);throw new ut("Cannot stream on this device")})}createTransceiverRTCRtpSender(e,n,r){return R(this,void 0,void 0,function*(){if(!this.pcManager)throw new ut("publisher is closed");const o=[];e.mediaStream&&o.push(e.mediaStream),Er(e)&&(e.codec=n.videoCodec);const l={direction:"sendonly",streams:o};return r&&(l.sendEncodings=r),(yield this.pcManager.addPublisherTransceiver(e.mediaStreamTrack,l)).sender})}createSimulcastTransceiverSender(e,n,r,o){return R(this,void 0,void 0,function*(){if(!this.pcManager)throw new ut("publisher is closed");const l={direction:"sendonly"};o&&(l.sendEncodings=o);const u=yield this.pcManager.addPublisherTransceiver(n.mediaStreamTrack,l);if(r.videoCodec)return e.setSimulcastTrackSender(r.videoCodec,u.sender),u.sender})}createRTCRtpSender(e){return R(this,void 0,void 0,function*(){if(!this.pcManager)throw new ut("publisher is closed");return this.pcManager.addPublisherTrack(e)})}attemptReconnect(e){return R(this,void 0,void 0,function*(){var n,r,o;if(!this._isClosed){if(this.attemptingReconnect){ke.warn("already attempting reconnect, returning early",this.logContext);return}(((n=this.clientConfiguration)===null||n===void 0?void 0:n.resumeConnection)===Bs.DISABLED||((o=(r=this.pcManager)===null||r===void 0?void 0:r.currentState)!==null&&o!==void 0?o:We.NEW)===We.NEW)&&(this.fullReconnectOnNext=!0);try{this.attemptingReconnect=!0,this.fullReconnectOnNext?yield this.restartConnection():yield this.resumeConnection(e),this.clearPendingReconnect(),this.fullReconnectOnNext=!1}catch(l){this.reconnectAttempts+=1;let u=!0;l instanceof ut?(this.log.debug("received unrecoverable error",Object.assign(Object.assign({},this.logContext),{error:l})),u=!1):l instanceof or||(this.fullReconnectOnNext=!0),u?this.handleDisconnect("reconnect",sr.RR_UNKNOWN):(this.log.info("could not recover connection after ".concat(this.reconnectAttempts," attempts, ").concat(Date.now()-this.reconnectStart,"ms. giving up"),this.logContext),this.emit(ne.Disconnected),yield this.close())}finally{this.attemptingReconnect=!1}}})}getNextRetryDelay(e){try{return this.reconnectPolicy.nextRetryDelayInMs(e)}catch(n){this.log.warn("encountered error in reconnect policy",Object.assign(Object.assign({},this.logContext),{error:n}))}return null}restartConnection(e){return R(this,void 0,void 0,function*(){var n,r,o;try{if(!this.url||!this.token)throw new ut("could not reconnect, url or token not saved");this.log.info("reconnecting, attempt: ".concat(this.reconnectAttempts),this.logContext),this.emit(ne.Restarting),this.client.isDisconnected||(yield this.client.sendLeave()),yield this.cleanupPeerConnections(),yield this.cleanupClient();let l;try{if(!this.signalOpts)throw this.log.warn("attempted connection restart, without signal options present",this.logContext),new or;l=yield this.join(e??this.url,this.token,this.signalOpts)}catch(u){throw u instanceof Ie&&u.reason===Re.NotAllowed?new ut("could not reconnect, token might be expired"):new or}if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(this.client.setReconnected(),this.emit(ne.SignalRestarted,l),yield this.waitForPCReconnected(),this.client.currentState!==He.CONNECTED)throw new or("Signal connection got severed during reconnect");(n=this.regionUrlProvider)===null||n===void 0||n.resetAttempts(),this.emit(ne.Restarted)}catch(l){const u=yield(r=this.regionUrlProvider)===null||r===void 0?void 0:r.getNextBestRegionUrl();if(u){yield this.restartConnection(u);return}else throw(o=this.regionUrlProvider)===null||o===void 0||o.resetAttempts(),l}})}resumeConnection(e){return R(this,void 0,void 0,function*(){var n;if(!this.url||!this.token)throw new ut("could not reconnect, url or token not saved");if(!this.pcManager)throw new ut("publisher and subscriber connections unset");this.log.info("resuming signal connection, attempt ".concat(this.reconnectAttempts),this.logContext),this.emit(ne.Resuming);let r;try{this.setupSignalClientCallbacks(),r=yield this.client.reconnect(this.url,this.token,this.participantSid,e)}catch(o){let l="";throw o instanceof Error&&(l=o.message,this.log.error(o.message,Object.assign(Object.assign({},this.logContext),{error:o}))),o instanceof Ie&&o.reason===Re.NotAllowed?new ut("could not reconnect, token might be expired"):o instanceof Ie&&o.reason===Re.LeaveRequest?o:new or(l)}if(this.emit(ne.SignalResumed),r){const o=this.makeRTCConfiguration(r);this.pcManager.updateConfiguration(o)}else this.log.warn("Did not receive reconnect response",this.logContext);if(this.shouldFailNext)throw this.shouldFailNext=!1,new Error("simulated failure");if(yield this.pcManager.triggerIceRestart(),yield this.waitForPCReconnected(),this.client.currentState!==He.CONNECTED)throw new or("Signal connection got severed during reconnect");this.client.setReconnected(),((n=this.reliableDC)===null||n===void 0?void 0:n.readyState)==="open"&&this.reliableDC.id===null&&this.createDataChannels(),this.emit(ne.Resumed)})}waitForPCInitialConnection(e,n){return R(this,void 0,void 0,function*(){if(!this.pcManager)throw new ut("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(n,e)})}waitForPCReconnected(){return R(this,void 0,void 0,function*(){this.pcState=dn.Reconnecting,this.log.debug("waiting for peer connection to reconnect",this.logContext);try{if(yield Nt(x1),!this.pcManager)throw new ut("PC manager is closed");yield this.pcManager.ensurePCTransportConnection(void 0,this.peerConnectionTimeout),this.pcState=dn.Connected}catch(e){throw this.pcState=dn.Disconnected,new Ie("could not establish PC connection, ".concat(e.message),Re.InternalError)}})}publishRpcResponse(e,n,r,o){return R(this,void 0,void 0,function*(){const l=new Mt({destinationIdentities:[e],kind:_e.RELIABLE,value:{case:"rpcResponse",value:new V0({requestId:n,value:o?{case:"error",value:o.toProto()}:{case:"payload",value:r??""}})}});yield this.sendDataPacket(l,_e.RELIABLE)})}publishRpcAck(e,n){return R(this,void 0,void 0,function*(){const r=new Mt({destinationIdentities:[e],kind:_e.RELIABLE,value:{case:"rpcAck",value:new q0({requestId:n})}});yield this.sendDataPacket(r,_e.RELIABLE)})}sendDataPacket(e,n){return R(this,void 0,void 0,function*(){const r=e.toBinary();yield this.ensurePublisherConnected(n);const o=this.dataChannelForKind(n);o&&o.send(r),this.updateAndEmitDCBufferStatus(n)})}waitForBufferStatusLow(e){return new Promise((n,r)=>R(this,void 0,void 0,function*(){if(this.isBufferStatusLow(e))n();else{const o=()=>r("Engine closed");for(this.once(ne.Closing,o);!this.dcBufferStatus.get(e);)yield Nt(10);this.off(ne.Closing,o),n()}}))}ensureDataTransportConnected(e){return R(this,arguments,void 0,function(n){var r=this;let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.subscriberPrimary;return function*(){var l;if(!r.pcManager)throw new ut("PC manager is closed");const u=o?r.pcManager.subscriber:r.pcManager.publisher,d=o?"Subscriber":"Publisher";if(!u)throw new Ie("".concat(d," connection not set"),Re.InternalError);let h=!1;!o&&!r.dataChannelForKind(n,o)&&(r.createDataChannels(),h=!0),!h&&!o&&!r.pcManager.publisher.isICEConnected&&r.pcManager.publisher.getICEConnectionState()!=="checking"&&(h=!0),h&&r.negotiate();const m=r.dataChannelForKind(n,o);if((m==null?void 0:m.readyState)==="open")return;const g=new Date().getTime()+r.peerConnectionTimeout;for(;new Date().getTime()<g;){if(u.isICEConnected&&((l=r.dataChannelForKind(n,o))===null||l===void 0?void 0:l.readyState)==="open")return;yield Nt(50)}throw new Ie("could not establish ".concat(d," connection, state: ").concat(u.getICEConnectionState()),Re.InternalError)}()})}ensurePublisherConnected(e){return R(this,void 0,void 0,function*(){this.publisherConnectionPromise||(this.publisherConnectionPromise=this.ensureDataTransportConnected(e,!1)),yield this.publisherConnectionPromise})}verifyTransport(){return!(!this.pcManager||this.pcManager.currentState!==We.CONNECTED||!this.client.ws||this.client.ws.readyState===WebSocket.CLOSED)}negotiate(){return R(this,void 0,void 0,function*(){return new Promise((e,n)=>R(this,void 0,void 0,function*(){if(!this.pcManager){n(new of("PC manager is closed"));return}this.pcManager.requirePublisher(),this.pcManager.publisher.getTransceivers().length==0&&!this.lossyDC&&!this.reliableDC&&this.createDataChannels();const r=new AbortController,o=()=>{r.abort(),this.log.debug("engine disconnected while negotiation was ongoing",this.logContext),e()};this.isClosed&&n("cannot negotiate on closed engine"),this.on(ne.Closing,o),this.pcManager.publisher.once(mr.RTPVideoPayloadTypes,l=>{const u=new Map;l.forEach(d=>{const h=d.codec.toLowerCase();XE(h)&&u.set(d.payload,h)}),this.emit(ne.RTPVideoMapUpdate,u)});try{yield this.pcManager.negotiate(r),e()}catch(l){l instanceof of&&(this.fullReconnectOnNext=!0),this.handleDisconnect("negotiation",sr.RR_UNKNOWN),n(l)}finally{this.off(ne.Closing,o)}}))})}dataChannelForKind(e,n){if(n){if(e===_e.LOSSY)return this.lossyDCSub;if(e===_e.RELIABLE)return this.reliableDCSub}else{if(e===_e.LOSSY)return this.lossyDC;if(e===_e.RELIABLE)return this.reliableDC}}sendSyncState(e,n){var r,o;if(!this.pcManager){this.log.warn("sync state cannot be sent without peer connection setup",this.logContext);return}const l=this.pcManager.subscriber.getLocalDescription(),u=this.pcManager.subscriber.getRemoteDescription(),d=(o=(r=this.signalOpts)===null||r===void 0?void 0:r.autoSubscribe)!==null&&o!==void 0?o:!0,h=new Array,m=new Array;e.forEach(g=>{g.isDesired!==d&&h.push(g.trackSid),g.isEnabled||m.push(g.trackSid)}),this.client.sendSyncState(new ay({answer:l?Nc({sdp:l.sdp,type:l.type}):void 0,offer:u?Nc({sdp:u.sdp,type:u.type}):void 0,subscription:new Fc({trackSids:h,subscribe:!d,participantTracks:[]}),publishTracks:i1(n),dataChannels:this.dataChannelsInfo(),trackSidsDisabled:m}))}failNext(){this.shouldFailNext=!0}dataChannelsInfo(){const e=[],n=(r,o)=>{(r==null?void 0:r.id)!==void 0&&r.id!==null&&e.push(new ry({label:r.label,id:r.id,target:o}))};return n(this.dataChannelForKind(_e.LOSSY),mn.PUBLISHER),n(this.dataChannelForKind(_e.RELIABLE),mn.PUBLISHER),n(this.dataChannelForKind(_e.LOSSY,!0),mn.SUBSCRIBER),n(this.dataChannelForKind(_e.RELIABLE,!0),mn.SUBSCRIBER),e}clearReconnectTimeout(){this.reconnectTimeout&&Tt.clearTimeout(this.reconnectTimeout)}clearPendingReconnect(){this.clearReconnectTimeout(),this.reconnectAttempts=0}registerOnLineListener(){xt()&&window.addEventListener("online",this.handleBrowserOnLine)}deregisterOnLineListener(){xt()&&window.removeEventListener("online",this.handleBrowserOnLine)}}class or extends Error{}function U1(a){return a!==void 0&&a>13}function L1(a,e){const n=a.participantIdentity?a.participantIdentity:e.participantIdentity;a.participantIdentity=n,e.participantIdentity=n;const r=a.destinationIdentities.length!==0?a.destinationIdentities:e.destinationIdentities;a.destinationIdentities=r,e.destinationIdentities=r}class bf{constructor(e,n){this.lastUpdateAt=0,this.settingsCacheTime=3e3,this.attemptedRegions=[],this.serverUrl=new URL(e),this.token=n}updateToken(e){this.token=e}isCloud(){return hf(this.serverUrl)}getServerUrl(){return this.serverUrl}getNextBestRegionUrl(e){return R(this,void 0,void 0,function*(){if(!this.isCloud())throw Error("region availability is only supported for LiveKit Cloud domains");(!this.regionSettings||Date.now()-this.lastUpdateAt>this.settingsCacheTime)&&(this.regionSettings=yield this.fetchRegionSettings(e));const n=this.regionSettings.regions.filter(r=>!this.attemptedRegions.find(o=>o.url===r.url));if(n.length>0){const r=n[0];return this.attemptedRegions.push(r),ke.debug("next region: ".concat(r.region)),r.url}else return null})}resetAttempts(){this.attemptedRegions=[]}fetchRegionSettings(e){return R(this,void 0,void 0,function*(){const n=yield fetch("".concat(I1(this.serverUrl),"/regions"),{headers:{authorization:"Bearer ".concat(this.token)},signal:e});if(n.ok){const r=yield n.json();return this.lastUpdateAt=Date.now(),r}else throw new Ie("Could not fetch region settings: ".concat(n.statusText),n.status===401?Re.NotAllowed:Re.InternalError,n.status)})}setServerReportedRegions(e){this.regionSettings=e,this.lastUpdateAt=Date.now()}}function I1(a){return"".concat(a.protocol.replace("ws","http"),"//").concat(a.host,"/settings")}class Wy{get info(){return this._info}constructor(e,n,r){this.reader=n,this.totalByteSize=r,this._info=e,this.bytesReceived=0}}class j1 extends Wy{handleChunkReceived(e){var n;this.bytesReceived+=e.content.byteLength;const r=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(n=this.onProgress)===null||n===void 0||n.call(this,r)}[Symbol.asyncIterator](){const e=this.reader.getReader();return{next:()=>R(this,void 0,void 0,function*(){try{const{done:n,value:r}=yield e.read();return n?{done:!0,value:void 0}:(this.handleChunkReceived(r),{done:!1,value:r.content})}catch{return{done:!0,value:void 0}}}),return(){return R(this,void 0,void 0,function*(){return e.releaseLock(),{done:!0,value:void 0}})}}}readAll(){return R(this,void 0,void 0,function*(){var e,n,r,o;let l=new Set;try{for(var u=!0,d=xi(this),h;h=yield d.next(),e=h.done,!e;u=!0){o=h.value,u=!1;const m=o;l.add(m)}}catch(m){n={error:m}}finally{try{!u&&!e&&(r=d.return)&&(yield r.call(d))}finally{if(n)throw n.error}}return Array.from(l)})}}class B1 extends Wy{constructor(e,n,r){super(e,n,r),this.receivedChunks=new Map}handleChunkReceived(e){var n;const r=Oc(e.chunkIndex),o=this.receivedChunks.get(r);if(o&&o.version>e.version)return;this.receivedChunks.set(r,e),this.bytesReceived+=e.content.byteLength;const l=this.totalByteSize?this.bytesReceived/this.totalByteSize:void 0;(n=this.onProgress)===null||n===void 0||n.call(this,l)}[Symbol.asyncIterator](){const e=this.reader.getReader(),n=new TextDecoder;return{next:()=>R(this,void 0,void 0,function*(){try{const{done:r,value:o}=yield e.read();return r?{done:!0,value:void 0}:(this.handleChunkReceived(o),{done:!1,value:n.decode(o.content)})}catch{return{done:!0,value:void 0}}}),return(){return R(this,void 0,void 0,function*(){return e.releaseLock(),{done:!0,value:void 0}})}}}readAll(){return R(this,void 0,void 0,function*(){var e,n,r,o;let l="";try{for(var u=!0,d=xi(this),h;h=yield d.next(),e=h.done,!e;u=!0)o=h.value,u=!1,l+=o}catch(m){n={error:m}}finally{try{!u&&!e&&(r=d.return)&&(yield r.call(d))}finally{if(n)throw n.error}}return l})}}class z1{constructor(e,n,r){this.writableStream=e,this.defaultWriter=e.getWriter(),this.onClose=r,this.info=n}write(e){return this.defaultWriter.write(e)}close(){return R(this,void 0,void 0,function*(){var e;yield this.defaultWriter.close(),this.defaultWriter.releaseLock(),(e=this.onClose)===null||e===void 0||e.call(this)})}}class q1 extends z1{}class $y extends j{constructor(e,n,r,o,l){super(e,r,l),this.sid=n,this.receiver=o}get isLocal(){return!1}setMuted(e){this.isMuted!==e&&(this.isMuted=e,this._mediaStreamTrack.enabled=!e,this.emit(e?W.Muted:W.Unmuted,this))}setMediaStream(e){this.mediaStream=e;const n=r=>{r.track===this._mediaStreamTrack&&(e.removeEventListener("removetrack",n),this.receiver&&"playoutDelayHint"in this.receiver&&(this.receiver.playoutDelayHint=void 0),this.receiver=void 0,this._currentBitrate=0,this.emit(W.Ended,this))};e.addEventListener("removetrack",n)}start(){this.startMonitor(),super.enable()}stop(){this.stopMonitor(),super.disable()}getRTCStatsReport(){return R(this,void 0,void 0,function*(){var e;return!((e=this.receiver)===null||e===void 0)&&e.getStats?yield this.receiver.getStats():void 0})}setPlayoutDelay(e){this.receiver?"playoutDelayHint"in this.receiver?this.receiver.playoutDelayHint=e:this.log.warn("Playout delay not supported in this browser"):this.log.warn("Cannot set playout delay, track already ended")}getPlayoutDelay(){if(this.receiver){if("playoutDelayHint"in this.receiver)return this.receiver.playoutDelayHint;this.log.warn("Playout delay not supported in this browser")}else this.log.warn("Cannot get playout delay, track already ended");return 0}startMonitor(){this.monitorInterval||(this.monitorInterval=setInterval(()=>this.monitorReceiver(),Jf)),a1()&&this.registerTimeSyncUpdate()}registerTimeSyncUpdate(){const e=()=>{var n;this.timeSyncHandle=requestAnimationFrame(()=>e());const r=(n=this.receiver)===null||n===void 0?void 0:n.getSynchronizationSources()[0];if(r){const{timestamp:o,rtpTimestamp:l}=r;l&&this.rtpTimestamp!==l&&(this.emit(W.TimeSyncUpdate,{timestamp:o,rtpTimestamp:l}),this.rtpTimestamp=l)}};e()}}class eb extends $y{constructor(e,n,r,o,l,u){super(e,n,j.Kind.Audio,r,u),this.monitorReceiver=()=>R(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const d=yield this.getReceiverStats();d&&this.prevStats&&this.receiver&&(this._currentBitrate=Xc(d,this.prevStats)),this.prevStats=d}),this.audioContext=o,this.webAudioPluginNodes=[],l&&(this.sinkId=l.deviceId)}setVolume(e){var n;for(const r of this.attachedElements)this.audioContext?(n=this.gainNode)===null||n===void 0||n.gain.setTargetAtTime(e,0,.1):r.volume=e;An()&&this._mediaStreamTrack._setVolume(e),this.elementVolume=e}getVolume(){if(this.elementVolume)return this.elementVolume;if(An())return 1;let e=0;return this.attachedElements.forEach(n=>{n.volume>e&&(e=n.volume)}),e}setSinkId(e){return R(this,void 0,void 0,function*(){this.sinkId=e,yield Promise.all(this.attachedElements.map(n=>{if(ff(n))return n.setSinkId(e)}))})}attach(e){const n=this.attachedElements.length===0;return e?super.attach(e):e=super.attach(),this.sinkId&&ff(e)&&e.setSinkId(this.sinkId),this.audioContext&&n&&(this.log.debug("using audio context mapping",this.logContext),this.connectWebAudio(this.audioContext,e),e.volume=0,e.muted=!0),this.elementVolume&&this.setVolume(this.elementVolume),e}detach(e){let n;return e?(n=super.detach(e),this.audioContext&&(this.attachedElements.length>0?this.connectWebAudio(this.audioContext,this.attachedElements[0]):this.disconnectWebAudio())):(n=super.detach(),this.disconnectWebAudio()),n}setAudioContext(e){this.audioContext=e,e&&this.attachedElements.length>0?this.connectWebAudio(e,this.attachedElements[0]):e||this.disconnectWebAudio()}setWebAudioPlugins(e){this.webAudioPluginNodes=e,this.attachedElements.length>0&&this.audioContext&&this.connectWebAudio(this.audioContext,this.attachedElements[0])}connectWebAudio(e,n){this.disconnectWebAudio(),this.sourceNode=e.createMediaStreamSource(n.srcObject);let r=this.sourceNode;this.webAudioPluginNodes.forEach(o=>{r.connect(o),r=o}),this.gainNode=e.createGain(),r.connect(this.gainNode),this.gainNode.connect(e.destination),this.elementVolume&&this.gainNode.gain.setTargetAtTime(this.elementVolume,0,.1),e.state!=="running"&&e.resume().then(()=>{e.state!=="running"&&this.emit(W.AudioPlaybackFailed,new Error("Audio Context couldn't be started automatically"))}).catch(o=>{this.emit(W.AudioPlaybackFailed,o)})}disconnectWebAudio(){var e,n;(e=this.gainNode)===null||e===void 0||e.disconnect(),(n=this.sourceNode)===null||n===void 0||n.disconnect(),this.gainNode=void 0,this.sourceNode=void 0}getReceiverStats(){return R(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let n;return e.forEach(r=>{r.type==="inbound-rtp"&&(n={type:"audio",streamId:r.id,timestamp:r.timestamp,jitter:r.jitter,bytesReceived:r.bytesReceived,concealedSamples:r.concealedSamples,concealmentEvents:r.concealmentEvents,silentConcealedSamples:r.silentConcealedSamples,silentConcealmentEvents:r.silentConcealmentEvents,totalAudioEnergy:r.totalAudioEnergy,totalSamplesDuration:r.totalSamplesDuration})}),n})}}const Id=100;class V1 extends $y{constructor(e,n,r,o,l){super(e,n,j.Kind.Video,r,l),this.elementInfos=[],this.monitorReceiver=()=>R(this,void 0,void 0,function*(){if(!this.receiver){this._currentBitrate=0;return}const u=yield this.getReceiverStats();u&&this.prevStats&&this.receiver&&(this._currentBitrate=Xc(u,this.prevStats)),this.prevStats=u}),this.debouncedHandleResize=Qf(()=>{this.updateDimensions()},Id),this.adaptiveStreamSettings=o}get isAdaptiveStream(){return this.adaptiveStreamSettings!==void 0}get mediaStreamTrack(){return this._mediaStreamTrack}setMuted(e){super.setMuted(e),this.attachedElements.forEach(n=>{e?fr(this._mediaStreamTrack,n):lr(this._mediaStreamTrack,n)})}attach(e){if(e?super.attach(e):e=super.attach(),this.adaptiveStreamSettings&&this.elementInfos.find(n=>n.element===e)===void 0){const n=new H1(e);this.observeElementInfo(n)}return e}observeElementInfo(e){this.adaptiveStreamSettings&&this.elementInfos.find(n=>n===e)===void 0?(e.handleResize=()=>{this.debouncedHandleResize()},e.handleVisibilityChanged=()=>{this.updateVisibility()},this.elementInfos.push(e),e.observe(),this.debouncedHandleResize(),this.updateVisibility()):this.log.warn("visibility resize observer not triggered",this.logContext)}stopObservingElementInfo(e){if(!this.isAdaptiveStream){this.log.warn("stopObservingElementInfo ignored",this.logContext);return}const n=this.elementInfos.filter(r=>r===e);for(const r of n)r.stopObserving();this.elementInfos=this.elementInfos.filter(r=>r!==e),this.updateVisibility(),this.debouncedHandleResize()}detach(e){let n=[];if(e)return this.stopObservingElement(e),super.detach(e);n=super.detach();for(const r of n)this.stopObservingElement(r);return n}getDecoderImplementation(){var e;return(e=this.prevStats)===null||e===void 0?void 0:e.decoderImplementation}getReceiverStats(){return R(this,void 0,void 0,function*(){if(!this.receiver||!this.receiver.getStats)return;const e=yield this.receiver.getStats();let n,r="",o=new Map;return e.forEach(l=>{l.type==="inbound-rtp"?(r=l.codecId,n={type:"video",streamId:l.id,framesDecoded:l.framesDecoded,framesDropped:l.framesDropped,framesReceived:l.framesReceived,packetsReceived:l.packetsReceived,packetsLost:l.packetsLost,frameWidth:l.frameWidth,frameHeight:l.frameHeight,pliCount:l.pliCount,firCount:l.firCount,nackCount:l.nackCount,jitter:l.jitter,timestamp:l.timestamp,bytesReceived:l.bytesReceived,decoderImplementation:l.decoderImplementation}):l.type==="codec"&&o.set(l.id,l)}),n&&r!==""&&o.get(r)&&(n.mimeType=o.get(r).mimeType),n})}stopObservingElement(e){const n=this.elementInfos.filter(r=>r.element===e);for(const r of n)this.stopObservingElementInfo(r)}handleAppVisibilityChanged(){const e=Object.create(null,{handleAppVisibilityChanged:{get:()=>super.handleAppVisibilityChanged}});return R(this,void 0,void 0,function*(){yield e.handleAppVisibilityChanged.call(this),this.isAdaptiveStream&&this.updateVisibility()})}updateVisibility(){var e,n;const r=this.elementInfos.reduce((d,h)=>Math.max(d,h.visibilityChangedAt||0),0),o=!((n=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pauseVideoInBackground)!==null&&n!==void 0)||n?this.isInBackground:!1,l=this.elementInfos.some(d=>d.pictureInPicture),u=this.elementInfos.some(d=>d.visible)&&!o||l;if(this.lastVisible!==u){if(!u&&Date.now()-r<Id){Tt.setTimeout(()=>{this.updateVisibility()},Id);return}this.lastVisible=u,this.emit(W.VisibilityChanged,u,this)}}updateDimensions(){var e,n;let r=0,o=0;const l=this.getPixelDensity();for(const u of this.elementInfos){const d=u.width()*l,h=u.height()*l;d+h>r+o&&(r=d,o=h)}((e=this.lastDimensions)===null||e===void 0?void 0:e.width)===r&&((n=this.lastDimensions)===null||n===void 0?void 0:n.height)===o||(this.lastDimensions={width:r,height:o},this.emit(W.VideoDimensionsChanged,this.lastDimensions,this))}getPixelDensity(){var e;const n=(e=this.adaptiveStreamSettings)===null||e===void 0?void 0:e.pixelDensity;return n==="screen"?Pv():n||(Pv()>2?2:1)}}class H1{get visible(){return this.isPiP||this.isIntersecting}get pictureInPicture(){return this.isPiP}constructor(e,n){this.onVisibilityChanged=r=>{var o;const{target:l,isIntersecting:u}=r;l===this.element&&(this.isIntersecting=u,this.isPiP=Ms(this.element),this.visibilityChangedAt=Date.now(),(o=this.handleVisibilityChanged)===null||o===void 0||o.call(this))},this.onEnterPiP=()=>{var r,o,l;(o=(r=window.documentPictureInPicture)===null||r===void 0?void 0:r.window)===null||o===void 0||o.addEventListener("pagehide",this.onLeavePiP),this.isPiP=Ms(this.element),(l=this.handleVisibilityChanged)===null||l===void 0||l.call(this)},this.onLeavePiP=()=>{var r;this.isPiP=Ms(this.element),(r=this.handleVisibilityChanged)===null||r===void 0||r.call(this)},this.element=e,this.isIntersecting=n??Sf(e),this.isPiP=xt()&&Ms(e),this.visibilityChangedAt=0}width(){return this.element.clientWidth}height(){return this.element.clientHeight}observe(){var e,n,r;this.isIntersecting=Sf(this.element),this.isPiP=Ms(this.element),this.element.handleResize=()=>{var o;(o=this.handleResize)===null||o===void 0||o.call(this)},this.element.handleVisibilityChanged=this.onVisibilityChanged,Nv().observe(this.element),xv().observe(this.element),this.element.addEventListener("enterpictureinpicture",this.onEnterPiP),this.element.addEventListener("leavepictureinpicture",this.onLeavePiP),(e=window.documentPictureInPicture)===null||e===void 0||e.addEventListener("enter",this.onEnterPiP),(r=(n=window.documentPictureInPicture)===null||n===void 0?void 0:n.window)===null||r===void 0||r.addEventListener("pagehide",this.onLeavePiP)}stopObserving(){var e,n,r,o,l;(e=Nv())===null||e===void 0||e.unobserve(this.element),(n=xv())===null||n===void 0||n.unobserve(this.element),this.element.removeEventListener("enterpictureinpicture",this.onEnterPiP),this.element.removeEventListener("leavepictureinpicture",this.onLeavePiP),(r=window.documentPictureInPicture)===null||r===void 0||r.removeEventListener("enter",this.onEnterPiP),(l=(o=window.documentPictureInPicture)===null||o===void 0?void 0:o.window)===null||l===void 0||l.removeEventListener("pagehide",this.onLeavePiP)}}function Ms(a){var e,n;return document.pictureInPictureElement===a?!0:!((e=window.documentPictureInPicture)===null||e===void 0)&&e.window?Sf(a,(n=window.documentPictureInPicture)===null||n===void 0?void 0:n.window):!1}function Sf(a,e){const n=e||window;let r=a.offsetTop,o=a.offsetLeft;const l=a.offsetWidth,u=a.offsetHeight,{hidden:d}=a,{display:h}=getComputedStyle(a);for(;a.offsetParent;)a=a.offsetParent,r+=a.offsetTop,o+=a.offsetLeft;return r<n.pageYOffset+n.innerHeight&&o<n.pageXOffset+n.innerWidth&&r+u>n.pageYOffset&&o+l>n.pageXOffset&&!d&&h!=="none"}class Pi extends xn.EventEmitter{constructor(e,n,r,o){var l;super(),this.metadataMuted=!1,this.encryption=Vt.NONE,this.log=ke,this.handleMuted=()=>{this.emit(W.Muted)},this.handleUnmuted=()=>{this.emit(W.Unmuted)},this.log=ei((l=o==null?void 0:o.loggerName)!==null&&l!==void 0?l:gn.Publication),this.loggerContextCb=this.loggerContextCb,this.setMaxListeners(100),this.kind=e,this.trackSid=n,this.trackName=r,this.source=j.Source.Unknown}setTrack(e){this.track&&(this.track.off(W.Muted,this.handleMuted),this.track.off(W.Unmuted,this.handleUnmuted)),this.track=e,e&&(e.on(W.Muted,this.handleMuted),e.on(W.Unmuted,this.handleUnmuted))}get logContext(){var e;return Object.assign(Object.assign({},(e=this.loggerContextCb)===null||e===void 0?void 0:e.call(this)),Me(this))}get isMuted(){return this.metadataMuted}get isEnabled(){return!0}get isSubscribed(){return this.track!==void 0}get isEncrypted(){return this.encryption!==Vt.NONE}get audioTrack(){if(ti(this.track))return this.track}get videoTrack(){if(Er(this.track))return this.track}updateInfo(e){this.trackSid=e.sid,this.trackName=e.name,this.source=j.sourceFromProto(e.source),this.mimeType=e.mimeType,this.kind===j.Kind.Video&&e.width>0&&(this.dimensions={width:e.width,height:e.height},this.simulcasted=e.simulcast),this.encryption=e.encryption,this.trackInfo=e,this.log.debug("update publication info",Object.assign(Object.assign({},this.logContext),{info:e}))}}(function(a){(function(e){e.Desired="desired",e.Subscribed="subscribed",e.Unsubscribed="unsubscribed"})(a.SubscriptionStatus||(a.SubscriptionStatus={})),function(e){e.Allowed="allowed",e.NotAllowed="not_allowed"}(a.PermissionStatus||(a.PermissionStatus={}))})(Pi);class Tf extends Pi{get isUpstreamPaused(){var e;return(e=this.track)===null||e===void 0?void 0:e.isUpstreamPaused}constructor(e,n,r,o){super(e,n.sid,n.name,o),this.track=void 0,this.handleTrackEnded=()=>{this.emit(W.Ended)},this.updateInfo(n),this.setTrack(r)}setTrack(e){this.track&&this.track.off(W.Ended,this.handleTrackEnded),super.setTrack(e),e&&e.on(W.Ended,this.handleTrackEnded)}get isMuted(){return this.track?this.track.isMuted:super.isMuted}get audioTrack(){return super.audioTrack}get videoTrack(){return super.videoTrack}get isLocal(){return!0}mute(){return R(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.mute()})}unmute(){return R(this,void 0,void 0,function*(){var e;return(e=this.track)===null||e===void 0?void 0:e.unmute()})}pauseUpstream(){return R(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.pauseUpstream()})}resumeUpstream(){return R(this,void 0,void 0,function*(){var e;yield(e=this.track)===null||e===void 0?void 0:e.resumeUpstream()})}getTrackFeatures(){var e;if(ti(this.track)){const n=this.track.getSourceTrackSettings(),r=new Set;return n.autoGainControl&&r.add(On.TF_AUTO_GAIN_CONTROL),n.echoCancellation&&r.add(On.TF_ECHO_CANCELLATION),n.noiseSuppression&&r.add(On.TF_NOISE_SUPPRESSION),n.channelCount&&n.channelCount>1&&r.add(On.TF_STEREO),!((e=this.options)===null||e===void 0)&&e.dtx||r.add(On.TF_NO_DTX),this.track.enhancedNoiseCancellation&&r.add(On.TF_ENHANCED_NOISE_CANCELLATION),Array.from(r.values())}else return[]}}var Ni;(function(a){a.Excellent="excellent",a.Good="good",a.Poor="poor",a.Lost="lost",a.Unknown="unknown"})(Ni||(Ni={}));function G1(a){switch(a){case xs.EXCELLENT:return Ni.Excellent;case xs.GOOD:return Ni.Good;case xs.POOR:return Ni.Poor;case xs.LOST:return Ni.Lost;default:return Ni.Unknown}}class tb extends xn.EventEmitter{get logContext(){var e,n;return Object.assign({},(n=(e=this.loggerOptions)===null||e===void 0?void 0:e.loggerContextCb)===null||n===void 0?void 0:n.call(e))}get isEncrypted(){return this.trackPublications.size>0&&Array.from(this.trackPublications.values()).every(e=>e.isEncrypted)}get isAgent(){var e;return((e=this.permissions)===null||e===void 0?void 0:e.agent)||this.kind===qs.AGENT}get kind(){return this._kind}get attributes(){return Object.freeze(Object.assign({},this._attributes))}constructor(e,n,r,o,l,u){let d=arguments.length>6&&arguments[6]!==void 0?arguments[6]:qs.STANDARD;var h;super(),this.audioLevel=0,this.isSpeaking=!1,this._connectionQuality=Ni.Unknown,this.log=ke,this.log=ei((h=u==null?void 0:u.loggerName)!==null&&h!==void 0?h:gn.Participant),this.loggerOptions=u,this.setMaxListeners(100),this.sid=e,this.identity=n,this.name=r,this.metadata=o,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this._kind=d,this._attributes=l??{}}getTrackPublications(){return Array.from(this.trackPublications.values())}getTrackPublication(e){for(const[,n]of this.trackPublications)if(n.source===e)return n}getTrackPublicationByName(e){for(const[,n]of this.trackPublications)if(n.trackName===e)return n}get connectionQuality(){return this._connectionQuality}get isCameraEnabled(){var e;const n=this.getTrackPublication(j.Source.Camera);return!(!((e=n==null?void 0:n.isMuted)!==null&&e!==void 0)||e)}get isMicrophoneEnabled(){var e;const n=this.getTrackPublication(j.Source.Microphone);return!(!((e=n==null?void 0:n.isMuted)!==null&&e!==void 0)||e)}get isScreenShareEnabled(){return!!this.getTrackPublication(j.Source.ScreenShare)}get isLocal(){return!1}get joinedAt(){return this.participantInfo?new Date(Number.parseInt(this.participantInfo.joinedAt.toString())*1e3):new Date}updateInfo(e){return this.participantInfo&&this.participantInfo.sid===e.sid&&this.participantInfo.version>e.version?!1:(this.identity=e.identity,this.sid=e.sid,this._setName(e.name),this._setMetadata(e.metadata),this._setAttributes(e.attributes),e.permission&&this.setPermissions(e.permission),this.participantInfo=e,this.log.trace("update participant info",Object.assign(Object.assign({},this.logContext),{info:e})),!0)}_setMetadata(e){const n=this.metadata!==e,r=this.metadata;this.metadata=e,n&&this.emit(F.ParticipantMetadataChanged,r)}_setName(e){const n=this.name!==e;this.name=e,n&&this.emit(F.ParticipantNameChanged,e)}_setAttributes(e){const n=r1(this.attributes,e);this._attributes=e,Object.keys(n).length>0&&this.emit(F.AttributesChanged,n)}setPermissions(e){var n,r,o,l,u,d;const h=this.permissions,m=e.canPublish!==((n=this.permissions)===null||n===void 0?void 0:n.canPublish)||e.canSubscribe!==((r=this.permissions)===null||r===void 0?void 0:r.canSubscribe)||e.canPublishData!==((o=this.permissions)===null||o===void 0?void 0:o.canPublishData)||e.hidden!==((l=this.permissions)===null||l===void 0?void 0:l.hidden)||e.recorder!==((u=this.permissions)===null||u===void 0?void 0:u.recorder)||e.canPublishSources.length!==this.permissions.canPublishSources.length||e.canPublishSources.some((g,y)=>{var b;return g!==((b=this.permissions)===null||b===void 0?void 0:b.canPublishSources[y])})||e.canSubscribeMetrics!==((d=this.permissions)===null||d===void 0?void 0:d.canSubscribeMetrics);return this.permissions=e,m&&this.emit(F.ParticipantPermissionsChanged,h),m}setIsSpeaking(e){e!==this.isSpeaking&&(this.isSpeaking=e,e&&(this.lastSpokeAt=new Date),this.emit(F.IsSpeakingChanged,e))}setConnectionQuality(e){const n=this._connectionQuality;this._connectionQuality=G1(e),n!==this._connectionQuality&&this.emit(F.ConnectionQualityChanged,this._connectionQuality)}setAudioContext(e){this.audioContext=e,this.audioTrackPublications.forEach(n=>ti(n.track)&&n.track.setAudioContext(e))}addTrackPublication(e){e.on(W.Muted,()=>{this.emit(F.TrackMuted,e)}),e.on(W.Unmuted,()=>{this.emit(F.TrackUnmuted,e)});const n=e;switch(n.track&&(n.track.sid=e.trackSid),this.trackPublications.set(e.trackSid,e),e.kind){case j.Kind.Audio:this.audioTrackPublications.set(e.trackSid,e);break;case j.Kind.Video:this.videoTrackPublications.set(e.trackSid,e);break}}}function F1(a){var e,n,r;if(!a.participantSid&&!a.participantIdentity)throw new Error("Invalid track permission, must provide at least one of participantIdentity and participantSid");return new ny({participantIdentity:(e=a.participantIdentity)!==null&&e!==void 0?e:"",participantSid:(n=a.participantSid)!==null&&n!==void 0?n:"",allTracks:(r=a.allowAll)!==null&&r!==void 0?r:!1,trackSids:a.allowedTrackSids||[]})}const hc=15e3;class Y1 extends tb{constructor(e,n,r,o,l){super(e,n,void 0,void 0,void 0,{loggerName:o.loggerName,loggerContextCb:()=>this.engine.logContext}),this.pendingPublishing=new Set,this.pendingPublishPromises=new Map,this.participantTrackPermissions=[],this.allParticipantsAllowedToSubscribe=!0,this.encryptionType=Vt.NONE,this.enabledPublishVideoCodecs=[],this.pendingAcks=new Map,this.pendingResponses=new Map,this.handleReconnecting=()=>{this.reconnectFuture||(this.reconnectFuture=new Vy)},this.handleReconnected=()=>{var u,d;(d=(u=this.reconnectFuture)===null||u===void 0?void 0:u.resolve)===null||d===void 0||d.call(u),this.reconnectFuture=void 0,this.updateTrackSubscriptionPermissions()},this.handleDisconnected=()=>{var u,d;this.reconnectFuture&&(this.reconnectFuture.promise.catch(h=>this.log.warn(h.message,this.logContext)),(d=(u=this.reconnectFuture)===null||u===void 0?void 0:u.reject)===null||d===void 0||d.call(u,"Got disconnected during reconnection attempt"),this.reconnectFuture=void 0)},this.handleSignalRequestResponse=u=>{const{requestId:d,reason:h,message:m}=u,g=this.pendingSignalRequests.get(d);g&&(h!==zf.OK&&g.reject(new Ov(m,h)),this.pendingSignalRequests.delete(d))},this.handleDataPacket=u=>{switch(u.value.case){case"rpcResponse":let d=u.value.value,h=null,m=null;d.value.case==="payload"?h=d.value.value:d.value.case==="error"&&(m=et.fromProto(d.value.value)),this.handleIncomingRpcResponse(d.requestId,h,m);break;case"rpcAck":let g=u.value.value;this.handleIncomingRpcAck(g.requestId);break}},this.updateTrackSubscriptionPermissions=()=>{this.log.debug("updating track subscription permissions",Object.assign(Object.assign({},this.logContext),{allParticipantsAllowed:this.allParticipantsAllowedToSubscribe,participantTrackPermissions:this.participantTrackPermissions})),this.engine.client.sendUpdateSubscriptionPermissions(this.allParticipantsAllowedToSubscribe,this.participantTrackPermissions.map(u=>F1(u)))},this.onTrackUnmuted=u=>{this.onTrackMuted(u,u.isUpstreamPaused)},this.onTrackMuted=(u,d)=>{if(d===void 0&&(d=!0),!u.sid){this.log.error("could not update mute status for unpublished track",Object.assign(Object.assign({},this.logContext),Me(u)));return}this.engine.updateMuteStatus(u.sid,d)},this.onTrackUpstreamPaused=u=>{this.log.debug("upstream paused",Object.assign(Object.assign({},this.logContext),Me(u))),this.onTrackMuted(u,!0)},this.onTrackUpstreamResumed=u=>{this.log.debug("upstream resumed",Object.assign(Object.assign({},this.logContext),Me(u))),this.onTrackMuted(u,u.isMuted)},this.onTrackFeatureUpdate=u=>{const d=this.audioTrackPublications.get(u.sid);if(!d){this.log.warn("Could not update local audio track settings, missing publication for track ".concat(u.sid),this.logContext);return}this.engine.client.sendUpdateLocalAudioTrack(d.trackSid,d.getTrackFeatures())},this.handleSubscribedQualityUpdate=u=>R(this,void 0,void 0,function*(){var d,h,m,g,y,b;if(!(!((y=this.roomOptions)===null||y===void 0)&&y.dynacast))return;const T=this.videoTrackPublications.get(u.trackSid);if(!T){this.log.warn("received subscribed quality update for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:u.trackSid}));return}if(u.subscribedCodecs.length>0){if(!T.videoTrack)return;const O=yield T.videoTrack.setPublishingCodecs(u.subscribedCodecs);try{for(var C=!0,k=xi(O),w;w=yield k.next(),d=w.done,!d;C=!0){g=w.value,C=!1;const V=g;IE(V)&&(this.log.debug("publish ".concat(V," for ").concat(T.videoTrack.sid),Object.assign(Object.assign({},this.logContext),Me(T))),yield this.publishAdditionalCodecForTrack(T.videoTrack,V,T.options))}}catch(V){h={error:V}}finally{try{!C&&!d&&(m=k.return)&&(yield m.call(k))}finally{if(h)throw h.error}}}else u.subscribedQualities.length>0&&(yield(b=T.videoTrack)===null||b===void 0?void 0:b.setPublishingLayers(u.subscribedQualities))}),this.handleLocalTrackUnpublished=u=>{const d=this.trackPublications.get(u.trackSid);if(!d){this.log.warn("received unpublished event for unknown track",Object.assign(Object.assign({},this.logContext),{trackSid:u.trackSid}));return}this.unpublishTrack(d.track)},this.handleTrackEnded=u=>R(this,void 0,void 0,function*(){if(u.source===j.Source.ScreenShare||u.source===j.Source.ScreenShareAudio)this.log.debug("unpublishing local track due to TrackEnded",Object.assign(Object.assign({},this.logContext),Me(u))),this.unpublishTrack(u);else if(u.isUserProvided)yield u.mute();else if(ha(u)||Ai(u))try{if(xt())try{const d=yield navigator==null?void 0:navigator.permissions.query({name:u.source===j.Source.Camera?"camera":"microphone"});if(d&&d.state==="denied")throw this.log.warn("user has revoked access to ".concat(u.source),Object.assign(Object.assign({},this.logContext),Me(u))),d.onchange=()=>{d.state!=="denied"&&(u.isMuted||u.restartTrack(),d.onchange=null)},new Error("GetUserMedia Permission denied")}catch{}u.isMuted||(this.log.debug("track ended, attempting to use a different device",Object.assign(Object.assign({},this.logContext),Me(u))),ha(u)?yield u.restartTrack({deviceId:"default"}):yield u.restartTrack())}catch{this.log.warn("could not restart track, muting instead",Object.assign(Object.assign({},this.logContext),Me(u))),yield u.mute()}}),this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.trackPublications=new Map,this.engine=r,this.roomOptions=o,this.setupEngine(r),this.activeDeviceMap=new Map([["audioinput","default"],["videoinput","default"],["audiooutput","default"]]),this.pendingSignalRequests=new Map,this.rpcHandlers=l}get lastCameraError(){return this.cameraError}get lastMicrophoneError(){return this.microphoneError}get isE2EEEnabled(){return this.encryptionType!==Vt.NONE}getTrackPublication(e){const n=super.getTrackPublication(e);if(n)return n}getTrackPublicationByName(e){const n=super.getTrackPublicationByName(e);if(n)return n}setupEngine(e){this.engine=e,this.engine.on(ne.RemoteMute,(n,r)=>{const o=this.trackPublications.get(n);!o||!o.track||(r?o.mute():o.unmute())}),this.engine.on(ne.Connected,this.handleReconnected).on(ne.SignalRestarted,this.handleReconnected).on(ne.SignalResumed,this.handleReconnected).on(ne.Restarting,this.handleReconnecting).on(ne.Resuming,this.handleReconnecting).on(ne.LocalTrackUnpublished,this.handleLocalTrackUnpublished).on(ne.SubscribedQualityUpdate,this.handleSubscribedQualityUpdate).on(ne.Disconnected,this.handleDisconnected).on(ne.SignalRequestResponse,this.handleSignalRequestResponse).on(ne.DataPacketReceived,this.handleDataPacket)}setMetadata(e){return R(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({metadata:e})})}setName(e){return R(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({name:e})})}setAttributes(e){return R(this,void 0,void 0,function*(){yield this.requestMetadataUpdate({attributes:e})})}requestMetadataUpdate(e){return R(this,arguments,void 0,function(n){var r=this;let{metadata:o,name:l,attributes:u}=n;return function*(){return new Promise((d,h)=>R(r,void 0,void 0,function*(){var m,g;try{let y=!1;const b=yield this.engine.client.sendUpdateLocalMetadata((m=o??this.metadata)!==null&&m!==void 0?m:"",(g=l??this.name)!==null&&g!==void 0?g:"",u),T=performance.now();for(this.pendingSignalRequests.set(b,{resolve:d,reject:C=>{h(C),y=!0},values:{name:l,metadata:o,attributes:u}});performance.now()-T<5e3&&!y;){if((!l||this.name===l)&&(!o||this.metadata===o)&&(!u||Object.entries(u).every(C=>{let[k,w]=C;return this.attributes[k]===w||w===""&&!this.attributes[k]}))){this.pendingSignalRequests.delete(b),d();return}yield Nt(50)}h(new Ov("Request to update local metadata timed out","TimeoutError"))}catch(y){y instanceof Error&&h(y)}}))}()})}setCameraEnabled(e,n,r){return this.setTrackEnabled(j.Source.Camera,e,n,r)}setMicrophoneEnabled(e,n,r){return this.setTrackEnabled(j.Source.Microphone,e,n,r)}setScreenShareEnabled(e,n,r){return this.setTrackEnabled(j.Source.ScreenShare,e,n,r)}setPermissions(e){const n=this.permissions,r=super.setPermissions(e);return r&&n&&this.emit(F.ParticipantPermissionsChanged,n),r}setE2EEEnabled(e){return R(this,void 0,void 0,function*(){this.encryptionType=e?Vt.GCM:Vt.NONE,yield this.republishAllTracks(void 0,!1)})}setTrackEnabled(e,n,r,o){return R(this,void 0,void 0,function*(){var l,u;this.log.debug("setTrackEnabled",Object.assign(Object.assign({},this.logContext),{source:e,enabled:n})),this.republishPromise&&(yield this.republishPromise);let d=this.getTrackPublication(e);if(n)if(d)yield d.unmute();else{let h;if(this.pendingPublishing.has(e)){const m=yield this.waitForPendingPublicationOfSource(e);return m||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e})),yield m==null?void 0:m.unmute(),m}this.pendingPublishing.add(e);try{switch(e){case j.Source.Camera:h=yield this.createTracks({video:(l=r)!==null&&l!==void 0?l:!0});break;case j.Source.Microphone:h=yield this.createTracks({audio:(u=r)!==null&&u!==void 0?u:!0});break;case j.Source.ScreenShare:h=yield this.createScreenTracks(Object.assign({},r));break;default:throw new $n(e)}}catch(m){throw h==null||h.forEach(g=>{g.stop()}),m instanceof Error&&this.emit(F.MediaDevicesError,m),this.pendingPublishing.delete(e),m}try{const m=[];for(const y of h)this.log.info("publishing track",Object.assign(Object.assign({},this.logContext),Me(y))),m.push(this.publishTrack(y,o));[d]=yield Promise.all(m)}catch(m){throw h==null||h.forEach(g=>{g.stop()}),m}finally{this.pendingPublishing.delete(e)}}else if(!(d!=null&&d.track)&&this.pendingPublishing.has(e)&&(d=yield this.waitForPendingPublicationOfSource(e),d||this.log.info("waiting for pending publication promise timed out",Object.assign(Object.assign({},this.logContext),{source:e}))),d&&d.track)if(e===j.Source.ScreenShare){d=yield this.unpublishTrack(d.track);const h=this.getTrackPublication(j.Source.ScreenShareAudio);h&&h.track&&this.unpublishTrack(h.track)}else yield d.mute();return d})}enableCameraAndMicrophone(){return R(this,void 0,void 0,function*(){if(!(this.pendingPublishing.has(j.Source.Camera)||this.pendingPublishing.has(j.Source.Microphone))){this.pendingPublishing.add(j.Source.Camera),this.pendingPublishing.add(j.Source.Microphone);try{const e=yield this.createTracks({audio:!0,video:!0});yield Promise.all(e.map(n=>this.publishTrack(n)))}finally{this.pendingPublishing.delete(j.Source.Camera),this.pendingPublishing.delete(j.Source.Microphone)}}})}createTracks(e){return R(this,void 0,void 0,function*(){var n,r;e??(e={});const o=Hy(e,(n=this.roomOptions)===null||n===void 0?void 0:n.audioCaptureDefaults,(r=this.roomOptions)===null||r===void 0?void 0:r.videoCaptureDefaults),{audioProcessor:l,videoProcessor:u,optionsWithoutProcessor:d}=Ff(o),h=Qc(d);let m;try{m=yield navigator.mediaDevices.getUserMedia(h)}catch(g){throw g instanceof Error&&(h.audio&&(this.microphoneError=g),h.video&&(this.cameraError=g)),g}return h.audio&&(this.microphoneError=void 0,this.emit(F.AudioStreamAcquired)),h.video&&(this.cameraError=void 0),Promise.all(m.getTracks().map(g=>R(this,void 0,void 0,function*(){const y=g.kind==="audio";let b;const T=y?h.audio:h.video;typeof T!="boolean"&&(b=T);const C=Xy(g,b,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});return C.kind===j.Kind.Video?C.source=j.Source.Camera:C.kind===j.Kind.Audio&&(C.source=j.Source.Microphone,C.setAudioContext(this.audioContext)),C.mediaStream=m,ti(C)&&l?yield C.setProcessor(l):Er(C)&&u&&(yield C.setProcessor(u)),C})))})}createScreenTracks(e){return R(this,void 0,void 0,function*(){if(e===void 0&&(e={}),navigator.mediaDevices.getDisplayMedia===void 0)throw new Vf("getDisplayMedia not supported");e.resolution===void 0&&!HE()&&(e.resolution=Hf.h1080fps30.resolution);const n=n1(e),r=yield navigator.mediaDevices.getDisplayMedia(n),o=r.getVideoTracks();if(o.length===0)throw new $n("no video track found");const l=new Lc(o[0],void 0,!1,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});l.source=j.Source.ScreenShare,e.contentHint&&(l.mediaStreamTrack.contentHint=e.contentHint);const u=[l];if(r.getAudioTracks().length>0){this.emit(F.AudioStreamAcquired);const d=new Uc(r.getAudioTracks()[0],void 0,!1,this.audioContext,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});d.source=j.Source.ScreenShareAudio,u.push(d)}return u})}publishTrack(e,n){return R(this,void 0,void 0,function*(){return this.publishOrRepublishTrack(e,n)})}publishOrRepublishTrack(e,n){return R(this,arguments,void 0,function(r,o){var l=this;let u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return function*(){var d,h,m,g;ha(r)&&r.setAudioContext(l.audioContext),yield(d=l.reconnectFuture)===null||d===void 0?void 0:d.promise,l.republishPromise&&!u&&(yield l.republishPromise),hr(r)&&l.pendingPublishPromises.has(r)&&(yield l.pendingPublishPromises.get(r));let y;if(r instanceof MediaStreamTrack)y=r.getConstraints();else{y=r.constraints;let O;switch(r.source){case j.Source.Microphone:O="audioinput";break;case j.Source.Camera:O="videoinput"}O&&l.activeDeviceMap.has(O)&&(y=Object.assign(Object.assign({},y),{deviceId:l.activeDeviceMap.get(O)}))}if(r instanceof MediaStreamTrack)switch(r.kind){case"audio":r=new Uc(r,y,!0,l.audioContext,{loggerName:l.roomOptions.loggerName,loggerContextCb:()=>l.logContext});break;case"video":r=new Lc(r,y,!0,{loggerName:l.roomOptions.loggerName,loggerContextCb:()=>l.logContext});break;default:throw new $n("unsupported MediaStreamTrack kind ".concat(r.kind))}else r.updateLoggerOptions({loggerName:l.roomOptions.loggerName,loggerContextCb:()=>l.logContext});let b;if(l.trackPublications.forEach(O=>{O.track&&O.track===r&&(b=O)}),b)return l.log.warn("track has already been published, skipping",Object.assign(Object.assign({},l.logContext),Me(b))),b;const T="channelCount"in r.mediaStreamTrack.getSettings()&&r.mediaStreamTrack.getSettings().channelCount===2||r.mediaStreamTrack.getConstraints().channelCount===2,C=(h=o==null?void 0:o.forceStereo)!==null&&h!==void 0?h:T;C&&(o||(o={}),o.dtx===void 0&&l.log.info("Opus DTX will be disabled for stereo tracks by default. Enable them explicitly to make it work.",Object.assign(Object.assign({},l.logContext),Me(r))),o.red===void 0&&l.log.info("Opus RED will be disabled for stereo tracks by default. Enable them explicitly to make it work."),(m=o.dtx)!==null&&m!==void 0||(o.dtx=!1),(g=o.red)!==null&&g!==void 0||(o.red=!1));const k=Object.assign(Object.assign({},l.roomOptions.publishDefaults),o);!GE()&&l.roomOptions.e2ee&&(l.log.info("End-to-end encryption is set up, simulcast publishing will be disabled on Safari versions and iOS browsers running iOS < v17.2",Object.assign({},l.logContext)),k.simulcast=!1),k.source&&(r.source=k.source);const w=l.publish(r,k,C);l.pendingPublishPromises.set(r,w);try{return yield w}catch(O){throw O}finally{l.pendingPublishPromises.delete(r)}}()})}hasPermissionsToPublish(e){if(!this.permissions)return this.log.warn("no permissions present for publishing track",Object.assign(Object.assign({},this.logContext),Me(e))),!1;const{canPublish:n,canPublishSources:r}=this.permissions;return n&&(r.length===0||r.map(o=>s1(o)).includes(e.source))?!0:(this.log.warn("insufficient permissions to publish",Object.assign(Object.assign({},this.logContext),Me(e))),!1)}publish(e,n,r){return R(this,void 0,void 0,function*(){var o,l,u,d,h,m,g,y,b,T;if(!this.hasPermissionsToPublish(e))throw new wE("failed to publish track, insufficient permissions",403);Array.from(this.trackPublications.values()).find(_=>hr(e)&&_.source===e.source)&&e.source!==j.Source.Unknown&&this.log.info("publishing a second track with the same source: ".concat(e.source),Object.assign(Object.assign({},this.logContext),Me(e))),n.stopMicTrackOnMute&&ti(e)&&(e.stopOnMute=!0),e.source===j.Source.ScreenShare&&br()&&(n.simulcast=!1),n.videoCodec==="av1"&&!zE()&&(n.videoCodec=void 0),n.videoCodec==="vp9"&&!qE()&&(n.videoCodec=void 0),n.videoCodec===void 0&&(n.videoCodec=gf),this.enabledPublishVideoCodecs.length>0&&(this.enabledPublishVideoCodecs.some(_=>n.videoCodec===Dc(_.mime))||(n.videoCodec=Dc(this.enabledPublishVideoCodecs[0].mime)));const k=n.videoCodec;e.on(W.Muted,this.onTrackMuted),e.on(W.Unmuted,this.onTrackUnmuted),e.on(W.Ended,this.handleTrackEnded),e.on(W.UpstreamPaused,this.onTrackUpstreamPaused),e.on(W.UpstreamResumed,this.onTrackUpstreamResumed),e.on(W.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate);const w=new Jd({cid:e.mediaStreamTrack.id,name:n.name,type:j.kindToProto(e.kind),muted:e.isMuted,source:j.sourceToProto(e.source),disableDtx:!(!((o=n.dtx)!==null&&o!==void 0)||o),encryption:this.encryptionType,stereo:r,disableRed:this.isE2EEEnabled||!(!((l=n.red)!==null&&l!==void 0)||l),stream:n==null?void 0:n.stream,backupCodecPolicy:n==null?void 0:n.backupCodecPolicy});let O;if(e.kind===j.Kind.Video){let _={width:0,height:0};try{_=yield e.waitForDimensions()}catch{const $=(d=(u=this.roomOptions.videoCaptureDefaults)===null||u===void 0?void 0:u.resolution)!==null&&d!==void 0?d:Hs.h720.resolution;_={width:$.width,height:$.height},this.log.error("could not determine track dimensions, using defaults",Object.assign(Object.assign(Object.assign({},this.logContext),Me(e)),{dims:_}))}w.width=_.width,w.height=_.height,Ai(e)&&(Is(k)&&(e.source===j.Source.ScreenShare&&(n.scalabilityMode="L1T3","contentHint"in e.mediaStreamTrack&&(e.mediaStreamTrack.contentHint="motion",this.log.info("forcing contentHint to motion for screenshare with SVC codecs",Object.assign(Object.assign({},this.logContext),Me(e))))),n.scalabilityMode=(h=n.scalabilityMode)!==null&&h!==void 0?h:"L3T3_KEY"),w.simulcastCodecs=[new Zd({codec:k,cid:e.mediaStreamTrack.id})],n.backupCodec===!0&&(n.backupCodec={codec:gf}),n.backupCodec&&k!==n.backupCodec.codec&&w.encryption===Vt.NONE&&(this.roomOptions.dynacast||(this.roomOptions.dynacast=!0),w.simulcastCodecs.push(new Zd({codec:n.backupCodec.codec,cid:""})))),O=yf(e.source===j.Source.ScreenShare,w.width,w.height,n),w.layers=Jv(w.width,w.height,O,Is(n.videoCodec))}else e.kind===j.Kind.Audio&&(O=[{maxBitrate:(m=n.audioPreset)===null||m===void 0?void 0:m.maxBitrate,priority:(y=(g=n.audioPreset)===null||g===void 0?void 0:g.priority)!==null&&y!==void 0?y:"high",networkPriority:(T=(b=n.audioPreset)===null||b===void 0?void 0:b.priority)!==null&&T!==void 0?T:"high"}]);if(!this.engine||this.engine.isClosed)throw new ut("cannot publish track when not connected");const V=()=>R(this,void 0,void 0,function*(){var _,H,$;if(!this.engine.pcManager)throw new ut("pcManager is not ready");if(e.sender=yield this.engine.createSender(e,n,O),Ai(e)&&((_=n.degradationPreference)!==null&&_!==void 0||(n.degradationPreference=M1(e)),e.setDegradationPreference(n.degradationPreference)),O)if(br()&&e.kind===j.Kind.Audio){let ie;for(const X of this.engine.pcManager.publisher.getTransceivers())if(X.sender===e.sender){ie=X;break}ie&&this.engine.pcManager.publisher.setTrackCodecBitrate({transceiver:ie,codec:"opus",maxbr:!((H=O[0])===null||H===void 0)&&H.maxBitrate?O[0].maxBitrate/1e3:0})}else e.codec&&Is(e.codec)&&(!(($=O[0])===null||$===void 0)&&$.maxBitrate)&&this.engine.pcManager.publisher.setTrackCodecBitrate({cid:w.cid,codec:e.codec,maxbr:O[0].maxBitrate/1e3});yield this.engine.negotiate()});let Q;if(this.enabledPublishVideoCodecs.length>0)Q=(yield Promise.all([this.engine.addTrack(w),V()]))[0];else{Q=yield this.engine.addTrack(w);let _;if(Q.codecs.forEach(H=>{_===void 0&&(_=H.mimeType)}),_&&e.kind===j.Kind.Video){const H=Dc(_);H!==k&&(this.log.debug("falling back to server selected codec",Object.assign(Object.assign(Object.assign({},this.logContext),Me(e)),{codec:H})),n.videoCodec=H,O=yf(e.source===j.Source.ScreenShare,w.width,w.height,n))}yield V()}const U=new Tf(e.kind,Q,e,{loggerName:this.roomOptions.loggerName,loggerContextCb:()=>this.logContext});return U.options=n,e.sid=Q.sid,this.log.debug("publishing ".concat(e.kind," with encodings"),Object.assign(Object.assign({},this.logContext),{encodings:O,trackInfo:Q})),Ai(e)?e.startMonitor(this.engine.client):ha(e)&&e.startMonitor(),this.addTrackPublication(U),this.emit(F.LocalTrackPublished,U),U})}get isLocal(){return!0}publishAdditionalCodecForTrack(e,n,r){return R(this,void 0,void 0,function*(){var o;if(this.encryptionType!==Vt.NONE)return;let l;if(this.trackPublications.forEach(T=>{T.track&&T.track===e&&(l=T)}),!l)throw new $n("track is not published");if(!Ai(e))throw new $n("track is not a video track");const u=Object.assign(Object.assign({},(o=this.roomOptions)===null||o===void 0?void 0:o.publishDefaults),r),d=O1(e,n,u);if(!d){this.log.info("backup codec has been disabled, ignoring request to add additional codec for track",Object.assign(Object.assign({},this.logContext),Me(e)));return}const h=e.addSimulcastTrack(n,d);if(!h)return;const m=new Jd({cid:h.mediaStreamTrack.id,type:j.kindToProto(e.kind),muted:e.isMuted,source:j.sourceToProto(e.source),sid:e.sid,simulcastCodecs:[{codec:u.videoCodec,cid:h.mediaStreamTrack.id}]});if(m.layers=Jv(m.width,m.height,d),!this.engine||this.engine.isClosed)throw new ut("cannot publish track when not connected");const g=()=>R(this,void 0,void 0,function*(){yield this.engine.createSimulcastSender(e,h,u,d),yield this.engine.negotiate()}),b=(yield Promise.all([this.engine.addTrack(m),g()]))[0];this.log.debug("published ".concat(n," for track ").concat(e.sid),Object.assign(Object.assign({},this.logContext),{encodings:d,trackInfo:b}))})}unpublishTrack(e,n){return R(this,void 0,void 0,function*(){var r,o;if(hr(e)){const m=this.pendingPublishPromises.get(e);m&&(this.log.info("awaiting publish promise before attempting to unpublish",Object.assign(Object.assign({},this.logContext),Me(e))),yield m)}const l=this.getPublicationForTrack(e),u=l?Me(l):void 0;if(this.log.debug("unpublishing track",Object.assign(Object.assign({},this.logContext),u)),!l||!l.track){this.log.warn("track was not unpublished because no publication was found",Object.assign(Object.assign({},this.logContext),u));return}e=l.track,e.off(W.Muted,this.onTrackMuted),e.off(W.Unmuted,this.onTrackUnmuted),e.off(W.Ended,this.handleTrackEnded),e.off(W.UpstreamPaused,this.onTrackUpstreamPaused),e.off(W.UpstreamResumed,this.onTrackUpstreamResumed),e.off(W.AudioTrackFeatureUpdate,this.onTrackFeatureUpdate),n===void 0&&(n=(o=(r=this.roomOptions)===null||r===void 0?void 0:r.stopLocalTrackOnUnpublish)!==null&&o!==void 0?o:!0),n?e.stop():e.stopMonitor();let d=!1;const h=e.sender;if(e.sender=void 0,this.engine.pcManager&&this.engine.pcManager.currentState<We.FAILED&&h)try{for(const m of this.engine.pcManager.publisher.getTransceivers())m.sender===h&&(m.direction="inactive",d=!0);if(this.engine.removeTrack(h)&&(d=!0),Ai(e)){for(const[,m]of e.simulcastCodecs)m.sender&&(this.engine.removeTrack(m.sender)&&(d=!0),m.sender=void 0);e.simulcastCodecs.clear()}}catch(m){this.log.warn("failed to unpublish track",Object.assign(Object.assign(Object.assign({},this.logContext),u),{error:m}))}switch(this.trackPublications.delete(l.trackSid),l.kind){case j.Kind.Audio:this.audioTrackPublications.delete(l.trackSid);break;case j.Kind.Video:this.videoTrackPublications.delete(l.trackSid);break}return this.emit(F.LocalTrackUnpublished,l),l.setTrack(void 0),d&&(yield this.engine.negotiate()),l})}unpublishTracks(e){return R(this,void 0,void 0,function*(){return(yield Promise.all(e.map(r=>this.unpublishTrack(r)))).filter(r=>!!r)})}republishAllTracks(e){return R(this,arguments,void 0,function(n){var r=this;let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return function*(){r.republishPromise&&(yield r.republishPromise),r.republishPromise=new Promise((l,u)=>R(r,void 0,void 0,function*(){try{const d=[];this.trackPublications.forEach(h=>{h.track&&(n&&(h.options=Object.assign(Object.assign({},h.options),n)),d.push(h))}),yield Promise.all(d.map(h=>R(this,void 0,void 0,function*(){const m=h.track;yield this.unpublishTrack(m,!1),o&&!m.isMuted&&m.source!==j.Source.ScreenShare&&m.source!==j.Source.ScreenShareAudio&&(ha(m)||Ai(m))&&!m.isUserProvided&&(this.log.debug("restarting existing track",Object.assign(Object.assign({},this.logContext),{track:h.trackSid})),yield m.restartTrack()),yield this.publishOrRepublishTrack(m,h.options,!0)}))),l()}catch(d){u(d)}finally{this.republishPromise=void 0}})),yield r.republishPromise}()})}publishData(e){return R(this,arguments,void 0,function(n){var r=this;let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return function*(){const l=o.reliable?_e.RELIABLE:_e.LOSSY,u=o.destinationIdentities,d=o.topic,h=new Mt({kind:l,value:{case:"user",value:new j0({participantIdentity:r.identity,payload:n,destinationIdentities:u,topic:d})}});yield r.engine.sendDataPacket(h,l)}()})}publishDtmf(e,n){return R(this,void 0,void 0,function*(){const r=new Mt({kind:_e.RELIABLE,value:{case:"sipDtmf",value:new B0({code:e,digit:n})}});yield this.engine.sendDataPacket(r,_e.RELIABLE)})}sendChatMessage(e,n){return R(this,void 0,void 0,function*(){const r={id:crypto.randomUUID(),message:e,timestamp:Date.now(),attachedFiles:n==null?void 0:n.attachments},o=new Mt({value:{case:"chatMessage",value:new Gd(Object.assign(Object.assign({},r),{timestamp:Ge.parse(r.timestamp)}))}});return yield this.engine.sendDataPacket(o,_e.RELIABLE),this.emit(F.ChatMessage,r),r})}editChatMessage(e,n){return R(this,void 0,void 0,function*(){const r=Object.assign(Object.assign({},n),{message:e,editTimestamp:Date.now()}),o=new Mt({value:{case:"chatMessage",value:new Gd(Object.assign(Object.assign({},r),{timestamp:Ge.parse(r.timestamp),editTimestamp:Ge.parse(r.editTimestamp)}))}});return yield this.engine.sendDataPacket(o,_e.RELIABLE),this.emit(F.ChatMessage,r),r})}sendText(e,n){return R(this,void 0,void 0,function*(){var r;const o=crypto.randomUUID(),u=new TextEncoder().encode(e).byteLength,d=(r=n==null?void 0:n.attachments)===null||r===void 0?void 0:r.map(()=>crypto.randomUUID()),h=new Array(d?d.length+1:1).fill(0),m=(y,b)=>{var T;h[b]=y;const C=h.reduce((k,w)=>k+w,0);(T=n==null?void 0:n.onProgress)===null||T===void 0||T.call(n,C)},g=yield this.streamText({streamId:o,totalSize:u,destinationIdentities:n==null?void 0:n.destinationIdentities,topic:n==null?void 0:n.topic,attachedStreamIds:d,attributes:n==null?void 0:n.attributes});return yield g.write(e),m(1,0),yield g.close(),n!=null&&n.attachments&&d&&(yield Promise.all(n.attachments.map((y,b)=>R(this,void 0,void 0,function*(){return this._sendFile(d[b],y,{topic:n.topic,mimeType:y.type,onProgress:T=>{m(T,b+1)}})})))),g.info})}streamText(e){return R(this,void 0,void 0,function*(){var n,r;const o=(n=e==null?void 0:e.streamId)!==null&&n!==void 0?n:crypto.randomUUID(),l={id:o,mimeType:"text/plain",timestamp:Date.now(),topic:(r=e==null?void 0:e.topic)!==null&&r!==void 0?r:"",size:e==null?void 0:e.totalSize,attributes:e==null?void 0:e.attributes},u=new Yd({streamId:o,mimeType:l.mimeType,topic:l.topic,timestamp:fa(l.timestamp),totalLength:fa(e==null?void 0:e.totalSize),attributes:l.attributes,contentHeader:{case:"textHeader",value:new X0({version:e==null?void 0:e.version,attachedStreamIds:e==null?void 0:e.attachedStreamIds,replyToStreamId:e==null?void 0:e.replyToStreamId,operationType:(e==null?void 0:e.type)==="update"?Fd.UPDATE:Fd.CREATE})}}),d=e==null?void 0:e.destinationIdentities,h=new Mt({destinationIdentities:d,value:{case:"streamHeader",value:u}});yield this.engine.sendDataPacket(h,_e.RELIABLE);let m=0;const g=this,y=new WritableStream({write(C){return R(this,void 0,void 0,function*(){for(const k of t1(C,hc)){yield g.engine.waitForBufferStatusLow(_e.RELIABLE);const w=new Kd({content:k,streamId:o,chunkIndex:fa(m)}),O=new Mt({destinationIdentities:d,value:{case:"streamChunk",value:w}});yield g.engine.sendDataPacket(O,_e.RELIABLE),m+=1}})},close(){return R(this,void 0,void 0,function*(){const C=new Qd({streamId:o}),k=new Mt({destinationIdentities:d,value:{case:"streamTrailer",value:C}});yield g.engine.sendDataPacket(k,_e.RELIABLE)})},abort(C){console.log("Sink error:",C)}});let b=()=>R(this,void 0,void 0,function*(){yield T.close()});g.engine.once(ne.Closing,b);const T=new q1(y,l,()=>this.engine.off(ne.Closing,b));return T})}sendFile(e,n){return R(this,void 0,void 0,function*(){const r=crypto.randomUUID();return yield this._sendFile(r,e,n),{id:r}})}_sendFile(e,n,r){return R(this,void 0,void 0,function*(){var o,l;const u=n.size,d=new Yd({totalLength:fa(u),mimeType:(o=r==null?void 0:r.mimeType)!==null&&o!==void 0?o:n.type,streamId:e,topic:r==null?void 0:r.topic,encryptionType:r==null?void 0:r.encryptionType,timestamp:fa(Date.now()),contentHeader:{case:"byteHeader",value:new Z0({name:n.name})}}),h=r==null?void 0:r.destinationIdentities,m=new Mt({destinationIdentities:h,value:{case:"streamHeader",value:d}});yield this.engine.sendDataPacket(m,_e.RELIABLE);function g(C){return new Promise(k=>{const w=new FileReader;w.onload=()=>{k(new Uint8Array(w.result))},w.readAsArrayBuffer(C)})}const y=Math.ceil(u/hc);for(let C=0;C<y;C++){const k=yield g(n.slice(C*hc,Math.min((C+1)*hc,u)));yield this.engine.waitForBufferStatusLow(_e.RELIABLE);const w=new Kd({content:k,streamId:e,chunkIndex:fa(C)}),O=new Mt({destinationIdentities:h,value:{case:"streamChunk",value:w}});yield this.engine.sendDataPacket(O,_e.RELIABLE),(l=r==null?void 0:r.onProgress)===null||l===void 0||l.call(r,(C+1)/y)}const b=new Qd({streamId:e}),T=new Mt({destinationIdentities:h,value:{case:"streamTrailer",value:b}});yield this.engine.sendDataPacket(T,_e.RELIABLE)})}performRpc(e){return R(this,arguments,void 0,function(n){var r=this;let{destinationIdentity:o,method:l,payload:u,responseTimeout:d=1e4}=n;return function*(){return new Promise((m,g)=>R(r,void 0,void 0,function*(){var y,b,T,C;if(Zf(u)>Ky){g(et.builtIn("REQUEST_PAYLOAD_TOO_LARGE"));return}if(!((b=(y=this.engine.latestJoinResponse)===null||y===void 0?void 0:y.serverInfo)===null||b===void 0)&&b.version&&Sr((C=(T=this.engine.latestJoinResponse)===null||T===void 0?void 0:T.serverInfo)===null||C===void 0?void 0:C.version,"1.8.0")<0){g(et.builtIn("UNSUPPORTED_SERVER"));return}const k=crypto.randomUUID();yield this.publishRpcRequest(o,k,l,u,d-2e3);const w=setTimeout(()=>{this.pendingAcks.delete(k),g(et.builtIn("CONNECTION_TIMEOUT")),this.pendingResponses.delete(k),clearTimeout(O)},2e3);this.pendingAcks.set(k,{resolve:()=>{clearTimeout(w)},participantIdentity:o});const O=setTimeout(()=>{this.pendingResponses.delete(k),g(et.builtIn("RESPONSE_TIMEOUT"))},d);this.pendingResponses.set(k,{resolve:(V,Q)=>{clearTimeout(O),this.pendingAcks.has(k)&&(console.warn("RPC response received before ack",k),this.pendingAcks.delete(k),clearTimeout(w)),Q?g(Q):m(V??"")},participantIdentity:o})}))}()})}registerRpcMethod(e,n){this.rpcHandlers.has(e)&&this.log.warn("you're overriding the RPC handler for method ".concat(e,", in the future this will throw an error")),this.rpcHandlers.set(e,n)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}setTrackSubscriptionPermissions(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];this.participantTrackPermissions=n,this.allParticipantsAllowedToSubscribe=e,this.engine.client.isDisconnected||this.updateTrackSubscriptionPermissions()}handleIncomingRpcAck(e){const n=this.pendingAcks.get(e);n?(n.resolve(),this.pendingAcks.delete(e)):console.error("Ack received for unexpected RPC request",e)}handleIncomingRpcResponse(e,n,r){const o=this.pendingResponses.get(e);o?(o.resolve(n,r),this.pendingResponses.delete(e)):console.error("Response received for unexpected RPC request",e)}publishRpcRequest(e,n,r,o,l){return R(this,void 0,void 0,function*(){const u=new Mt({destinationIdentities:[e],kind:_e.RELIABLE,value:{case:"rpcRequest",value:new z0({id:n,method:r,payload:o,responseTimeoutMs:l,version:1})}});yield this.engine.sendDataPacket(u,_e.RELIABLE)})}handleParticipantDisconnected(e){for(const[n,{participantIdentity:r}]of this.pendingAcks)r===e&&this.pendingAcks.delete(n);for(const[n,{participantIdentity:r,resolve:o}]of this.pendingResponses)r===e&&(o(null,et.builtIn("RECIPIENT_DISCONNECTED")),this.pendingResponses.delete(n))}setEnabledPublishCodecs(e){this.enabledPublishVideoCodecs=e.filter(n=>n.mime.split("/")[0].toLowerCase()==="video")}updateInfo(e){return e.sid!==this.sid||!super.updateInfo(e)?!1:(e.tracks.forEach(n=>{var r,o;const l=this.trackPublications.get(n.sid);if(l){const u=l.isMuted||((o=(r=l.track)===null||r===void 0?void 0:r.isUpstreamPaused)!==null&&o!==void 0?o:!1);u!==n.muted&&(this.log.debug("updating server mute state after reconcile",Object.assign(Object.assign(Object.assign({},this.logContext),Me(l)),{mutedOnServer:u})),this.engine.client.sendMuteTrack(n.sid,u))}}),!0)}getPublicationForTrack(e){let n;return this.trackPublications.forEach(r=>{const o=r.track;o&&(e instanceof MediaStreamTrack?(ha(o)||Ai(o))&&o.mediaStreamTrack===e&&(n=r):e===o&&(n=r))}),n}waitForPendingPublicationOfSource(e){return R(this,void 0,void 0,function*(){const r=Date.now();for(;Date.now()<r+1e4;){const o=Array.from(this.pendingPublishPromises.entries()).find(l=>{let[u]=l;return u.source===e});if(o)return o[1];yield Nt(20)}})}}class nb extends Pi{constructor(e,n,r,o){super(e,n.sid,n.name,o),this.track=void 0,this.allowed=!0,this.disabled=!1,this.currentVideoQuality=rn.HIGH,this.handleEnded=l=>{this.setTrack(void 0),this.emit(W.Ended,l)},this.handleVisibilityChange=l=>{this.log.debug("adaptivestream video visibility ".concat(this.trackSid,", visible=").concat(l),this.logContext),this.disabled=!l,this.emitTrackUpdate()},this.handleVideoDimensionsChange=l=>{this.log.debug("adaptivestream video dimensions ".concat(l.width,"x").concat(l.height),this.logContext),this.videoDimensions=l,this.emitTrackUpdate()},this.subscribed=r,this.updateInfo(n)}setSubscribed(e){const n=this.subscriptionStatus,r=this.permissionStatus;this.subscribed=e,e&&(this.allowed=!0);const o=new Fc({trackSids:[this.trackSid],subscribe:this.subscribed,participantTracks:[new G0({participantSid:"",trackSids:[this.trackSid]})]});this.emit(W.UpdateSubscription,o),this.emitSubscriptionUpdateIfChanged(n),this.emitPermissionUpdateIfChanged(r)}get subscriptionStatus(){return this.subscribed===!1?Pi.SubscriptionStatus.Unsubscribed:super.isSubscribed?Pi.SubscriptionStatus.Subscribed:Pi.SubscriptionStatus.Desired}get permissionStatus(){return this.allowed?Pi.PermissionStatus.Allowed:Pi.PermissionStatus.NotAllowed}get isSubscribed(){return this.subscribed===!1?!1:super.isSubscribed}get isDesired(){return this.subscribed!==!1}get isEnabled(){return!this.disabled}get isLocal(){return!1}setEnabled(e){!this.isManualOperationAllowed()||this.disabled===!e||(this.disabled=!e,this.emitTrackUpdate())}setVideoQuality(e){!this.isManualOperationAllowed()||this.currentVideoQuality===e||(this.currentVideoQuality=e,this.videoDimensions=void 0,this.emitTrackUpdate())}setVideoDimensions(e){var n,r;this.isManualOperationAllowed()&&(((n=this.videoDimensions)===null||n===void 0?void 0:n.width)===e.width&&((r=this.videoDimensions)===null||r===void 0?void 0:r.height)===e.height||(Ad(this.track)&&(this.videoDimensions=e),this.currentVideoQuality=void 0,this.emitTrackUpdate()))}setVideoFPS(e){this.isManualOperationAllowed()&&Ad(this.track)&&this.fps!==e&&(this.fps=e,this.emitTrackUpdate())}get videoQuality(){return this.currentVideoQuality}setTrack(e){const n=this.subscriptionStatus,r=this.permissionStatus,o=this.track;o!==e&&(o&&(o.off(W.VideoDimensionsChanged,this.handleVideoDimensionsChange),o.off(W.VisibilityChanged,this.handleVisibilityChange),o.off(W.Ended,this.handleEnded),o.detach(),o.stopMonitor(),this.emit(W.Unsubscribed,o)),super.setTrack(e),e&&(e.sid=this.trackSid,e.on(W.VideoDimensionsChanged,this.handleVideoDimensionsChange),e.on(W.VisibilityChanged,this.handleVisibilityChange),e.on(W.Ended,this.handleEnded),this.emit(W.Subscribed,e)),this.emitPermissionUpdateIfChanged(r),this.emitSubscriptionUpdateIfChanged(n))}setAllowed(e){const n=this.subscriptionStatus,r=this.permissionStatus;this.allowed=e,this.emitPermissionUpdateIfChanged(r),this.emitSubscriptionUpdateIfChanged(n)}setSubscriptionError(e){this.emit(W.SubscriptionFailed,e)}updateInfo(e){super.updateInfo(e);const n=this.metadataMuted;this.metadataMuted=e.muted,this.track?this.track.setMuted(e.muted):n!==e.muted&&this.emit(e.muted?W.Muted:W.Unmuted)}emitSubscriptionUpdateIfChanged(e){const n=this.subscriptionStatus;e!==n&&this.emit(W.SubscriptionStatusChanged,n,e)}emitPermissionUpdateIfChanged(e){this.permissionStatus!==e&&this.emit(W.SubscriptionPermissionChanged,this.permissionStatus,e)}isManualOperationAllowed(){return this.kind===j.Kind.Video&&this.isAdaptiveStream?(this.log.warn("adaptive stream is enabled, cannot change video track settings",this.logContext),!1):this.isDesired?!0:(this.log.warn("cannot update track settings when not subscribed",this.logContext),!1)}get isAdaptiveStream(){return Ad(this.track)&&this.track.isAdaptiveStream}emitTrackUpdate(){const e=new J0({trackSids:[this.trackSid],disabled:this.disabled,fps:this.fps});this.videoDimensions?(e.width=Math.ceil(this.videoDimensions.width),e.height=Math.ceil(this.videoDimensions.height)):this.currentVideoQuality!==void 0?e.quality=this.currentVideoQuality:e.quality=rn.HIGH,this.emit(W.UpdateSettings,e)}}class Ic extends tb{static fromParticipantInfo(e,n,r){return new Ic(e,n.sid,n.identity,n.name,n.metadata,n.attributes,r,n.kind)}get logContext(){return Object.assign(Object.assign({},super.logContext),{rpID:this.sid,remoteParticipant:this.identity})}constructor(e,n,r,o,l,u,d){let h=arguments.length>7&&arguments[7]!==void 0?arguments[7]:qs.STANDARD;super(n,r||"",o,l,u,d,h),this.signalClient=e,this.trackPublications=new Map,this.audioTrackPublications=new Map,this.videoTrackPublications=new Map,this.volumeMap=new Map}addTrackPublication(e){super.addTrackPublication(e),e.on(W.UpdateSettings,n=>{this.log.debug("send update settings",Object.assign(Object.assign({},this.logContext),Me(e))),this.signalClient.sendUpdateTrackSettings(n)}),e.on(W.UpdateSubscription,n=>{n.participantTracks.forEach(r=>{r.participantSid=this.sid}),this.signalClient.sendUpdateSubscription(n)}),e.on(W.SubscriptionPermissionChanged,n=>{this.emit(F.TrackSubscriptionPermissionChanged,e,n)}),e.on(W.SubscriptionStatusChanged,n=>{this.emit(F.TrackSubscriptionStatusChanged,e,n)}),e.on(W.Subscribed,n=>{this.emit(F.TrackSubscribed,n,e)}),e.on(W.Unsubscribed,n=>{this.emit(F.TrackUnsubscribed,n,e)}),e.on(W.SubscriptionFailed,n=>{this.emit(F.TrackSubscriptionFailed,e.trackSid,n)})}getTrackPublication(e){const n=super.getTrackPublication(e);if(n)return n}getTrackPublicationByName(e){const n=super.getTrackPublicationByName(e);if(n)return n}setVolume(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:j.Source.Microphone;this.volumeMap.set(n,e);const r=this.getTrackPublication(n);r&&r.track&&r.track.setVolume(e)}getVolume(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:j.Source.Microphone;const n=this.getTrackPublication(e);return n&&n.track?n.track.getVolume():this.volumeMap.get(e)}addSubscribedMediaTrack(e,n,r,o,l,u){let d=this.getTrackPublicationBySid(n);if(d||n.startsWith("TR")||this.trackPublications.forEach(g=>{!d&&e.kind===g.kind.toString()&&(d=g)}),!d){if(u===0){this.log.error("could not find published track",Object.assign(Object.assign({},this.logContext),{trackSid:n})),this.emit(F.TrackSubscriptionFailed,n);return}u===void 0&&(u=20),setTimeout(()=>{this.addSubscribedMediaTrack(e,n,r,o,l,u-1)},150);return}if(e.readyState==="ended"){this.log.error("unable to subscribe because MediaStreamTrack is ended. Do not call MediaStreamTrack.stop()",Object.assign(Object.assign({},this.logContext),Me(d))),this.emit(F.TrackSubscriptionFailed,n);return}const h=e.kind==="video";let m;return h?m=new V1(e,n,o,l):m=new eb(e,n,o,this.audioContext,this.audioOutput),m.source=d.source,m.isMuted=d.isMuted,m.setMediaStream(r),m.start(),d.setTrack(m),this.volumeMap.has(d.source)&&mf(m)&&ti(m)&&m.setVolume(this.volumeMap.get(d.source)),d}get hasMetadata(){return!!this.participantInfo}getTrackPublicationBySid(e){return this.trackPublications.get(e)}updateInfo(e){if(!super.updateInfo(e))return!1;const n=new Map,r=new Map;return e.tracks.forEach(o=>{var l,u;let d=this.getTrackPublicationBySid(o.sid);if(d)d.updateInfo(o);else{const h=j.kindFromProto(o.type);if(!h)return;d=new nb(h,o,(l=this.signalClient.connectOptions)===null||l===void 0?void 0:l.autoSubscribe,{loggerContextCb:()=>this.logContext,loggerName:(u=this.loggerOptions)===null||u===void 0?void 0:u.loggerName}),d.updateInfo(o),r.set(o.sid,d);const m=Array.from(this.trackPublications.values()).find(g=>g.source===(d==null?void 0:d.source));m&&d.source!==j.Source.Unknown&&this.log.debug("received a second track publication for ".concat(this.identity," with the same source: ").concat(d.source),Object.assign(Object.assign({},this.logContext),{oldTrack:Me(m),newTrack:Me(d)})),this.addTrackPublication(d)}n.set(o.sid,d)}),this.trackPublications.forEach(o=>{n.has(o.trackSid)||(this.log.trace("detected removed track on remote participant, unpublishing",Object.assign(Object.assign({},this.logContext),Me(o))),this.unpublishTrack(o.trackSid,!0))}),r.forEach(o=>{this.emit(F.TrackPublished,o)}),!0}unpublishTrack(e,n){const r=this.trackPublications.get(e);if(!r)return;const{track:o}=r;switch(o&&(o.stop(),r.setTrack(void 0)),this.trackPublications.delete(e),r.kind){case j.Kind.Audio:this.audioTrackPublications.delete(e);break;case j.Kind.Video:this.videoTrackPublications.delete(e);break}n&&this.emit(F.TrackUnpublished,r)}setAudioOutput(e){return R(this,void 0,void 0,function*(){this.audioOutput=e;const n=[];this.audioTrackPublications.forEach(r=>{var o;ti(r.track)&&mf(r.track)&&n.push(r.track.setSinkId((o=e.deviceId)!==null&&o!==void 0?o:"default"))}),yield Promise.all(n)})}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return this.log.trace("participant event",Object.assign(Object.assign({},this.logContext),{event:e,args:r})),super.emit(e,...r)}}var Te;(function(a){a.Disconnected="disconnected",a.Connecting="connecting",a.Connected="connected",a.Reconnecting="reconnecting",a.SignalReconnecting="signalReconnecting"})(Te||(Te={}));const K1=4*1e3;class ni extends xn.EventEmitter{constructor(e){var n,r,o,l;if(super(),n=this,this.state=Te.Disconnected,this.activeSpeakers=[],this.isE2EEEnabled=!1,this.audioEnabled=!0,this.isVideoPlaybackBlocked=!1,this.log=ke,this.bufferedEvents=[],this.isResuming=!1,this.byteStreamControllers=new Map,this.textStreamControllers=new Map,this.byteStreamHandlers=new Map,this.textStreamHandlers=new Map,this.rpcHandlers=new Map,this.connect=(u,d,h)=>R(this,void 0,void 0,function*(){var m;if(!VE())throw An()?Error("WebRTC isn't detected, have you called registerGlobals?"):Error("LiveKit doesn't seem to be supported on this browser. Try to update your browser and make sure no browser extensions are disabling webRTC.");const g=yield this.disconnectLock.lock();if(this.state===Te.Connected)return this.log.info("already connected to room ".concat(this.name),this.logContext),g(),Promise.resolve();if(this.connectFuture)return g(),this.connectFuture.promise;this.setAndEmitConnectionState(Te.Connecting),((m=this.regionUrlProvider)===null||m===void 0?void 0:m.getServerUrl().toString())!==u&&(this.regionUrl=void 0,this.regionUrlProvider=void 0),hf(new URL(u))&&(this.regionUrlProvider===void 0?this.regionUrlProvider=new bf(u,d):this.regionUrlProvider.updateToken(d),this.regionUrlProvider.fetchRegionSettings().then(T=>{var C;(C=this.regionUrlProvider)===null||C===void 0||C.setServerReportedRegions(T)}).catch(T=>{this.log.warn("could not fetch region settings",Object.assign(Object.assign({},this.logContext),{error:T}))}));const y=(T,C,k)=>R(this,void 0,void 0,function*(){var w,O;this.abortController&&this.abortController.abort();const V=new AbortController;this.abortController=V,g==null||g();try{yield this.attemptConnection(k??u,d,h,V),this.abortController=void 0,T()}catch(Q){if(this.regionUrlProvider&&Q instanceof Ie&&Q.reason!==Re.Cancelled&&Q.reason!==Re.NotAllowed){let U=null;try{U=yield this.regionUrlProvider.getNextBestRegionUrl((w=this.abortController)===null||w===void 0?void 0:w.signal)}catch(_){if(_ instanceof Ie&&(_.status===401||_.reason===Re.Cancelled)){this.handleDisconnect(this.options.stopLocalTrackOnUnpublish),C(_);return}}U&&!(!((O=this.abortController)===null||O===void 0)&&O.signal.aborted)?(this.log.info("Initial connection failed with ConnectionError: ".concat(Q.message,". Retrying with another region: ").concat(U),this.logContext),this.recreateEngine(),yield y(T,C,U)):(this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,Iv(Q)),C(Q))}else{let U=pn.UNKNOWN_REASON;Q instanceof Ie&&(U=Iv(Q)),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,U),C(Q)}}}),b=this.regionUrl;return this.regionUrl=void 0,this.connectFuture=new Vy((T,C)=>{y(T,C,b)},()=>{this.clearConnectionFutures()}),this.connectFuture.promise}),this.connectSignal=(u,d,h,m,g,y)=>R(this,void 0,void 0,function*(){var b,T,C;const k=yield h.join(u,d,{autoSubscribe:m.autoSubscribe,adaptiveStream:typeof g.adaptiveStream=="object"?!0:g.adaptiveStream,maxRetries:m.maxRetries,e2eeEnabled:!!this.e2eeManager,websocketTimeout:m.websocketTimeout},y.signal);let w=k.serverInfo;if(w||(w={version:k.serverVersion,region:k.serverRegion}),this.serverInfo=w,this.log.debug("connected to Livekit Server ".concat(Object.entries(w).map(O=>{let[V,Q]=O;return"".concat(V,": ").concat(Q)}).join(", ")),{room:(b=k.room)===null||b===void 0?void 0:b.name,roomSid:(T=k.room)===null||T===void 0?void 0:T.sid,identity:(C=k.participant)===null||C===void 0?void 0:C.identity}),!w.version)throw new _E("unknown server version");return w.version==="0.15.1"&&this.options.dynacast&&(this.log.debug("disabling dynacast due to server version",this.logContext),g.dynacast=!1),k}),this.applyJoinResponse=u=>{const d=u.participant;if(this.localParticipant.sid=d.sid,this.localParticipant.identity=d.identity,this.localParticipant.setEnabledPublishCodecs(u.enabledPublishCodecs),this.options.e2ee&&this.e2eeManager)try{this.e2eeManager.setSifTrailer(u.sifTrailer)}catch(h){this.log.error(h instanceof Error?h.message:"Could not set SifTrailer",Object.assign(Object.assign({},this.logContext),{error:h}))}this.handleParticipantUpdates([d,...u.otherParticipants]),u.room&&this.handleRoomUpdate(u.room)},this.attemptConnection=(u,d,h,m)=>R(this,void 0,void 0,function*(){var g,y;this.state===Te.Reconnecting||this.isResuming||!((g=this.engine)===null||g===void 0)&&g.pendingReconnect?(this.log.info("Reconnection attempt replaced by new connection attempt",this.logContext),this.recreateEngine()):this.maybeCreateEngine(),!((y=this.regionUrlProvider)===null||y===void 0)&&y.isCloud()&&this.engine.setRegionUrlProvider(this.regionUrlProvider),this.acquireAudioContext(),this.connOptions=Object.assign(Object.assign({},Xf),h),this.connOptions.rtcConfig&&(this.engine.rtcConfig=this.connOptions.rtcConfig),this.connOptions.peerConnectionTimeout&&(this.engine.peerConnectionTimeout=this.connOptions.peerConnectionTimeout);try{const b=yield this.connectSignal(u,d,this.engine,this.connOptions,this.options,m);this.applyJoinResponse(b),this.setupLocalParticipantEvents(),this.emit(B.SignalConnected)}catch(b){yield this.engine.close(),this.recreateEngine();const T=new Ie("could not establish signal connection",Re.ServerUnreachable);throw b instanceof Error&&(T.message="".concat(T.message,": ").concat(b.message)),b instanceof Ie&&(T.reason=b.reason,T.status=b.status),this.log.debug("error trying to establish signal connection",Object.assign(Object.assign({},this.logContext),{error:b})),T}if(m.signal.aborted)throw yield this.engine.close(),this.recreateEngine(),new Ie("Connection attempt aborted",Re.Cancelled);try{yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout,m)}catch(b){throw yield this.engine.close(),this.recreateEngine(),b}xt()&&this.options.disconnectOnPageLeave&&(window.addEventListener("pagehide",this.onPageLeave),window.addEventListener("beforeunload",this.onPageLeave)),xt()&&document.addEventListener("freeze",this.onPageLeave),this.setAndEmitConnectionState(Te.Connected),this.emit(B.Connected),this.registerConnectionReconcile()}),this.disconnect=function(){for(var u=arguments.length,d=new Array(u),h=0;h<u;h++)d[h]=arguments[h];return R(n,[...d],void 0,function(){var m=this;let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;return function*(){var y,b,T,C;const k=yield m.disconnectLock.lock();try{if(m.state===Te.Disconnected){m.log.debug("already disconnected",m.logContext);return}m.log.info("disconnect from room",Object.assign({},m.logContext)),(m.state===Te.Connecting||m.state===Te.Reconnecting||m.isResuming)&&(m.log.warn("abort connection attempt",m.logContext),(y=m.abortController)===null||y===void 0||y.abort(),(T=(b=m.connectFuture)===null||b===void 0?void 0:b.reject)===null||T===void 0||T.call(b,new Ie("Client initiated disconnect",Re.Cancelled)),m.connectFuture=void 0),!((C=m.engine)===null||C===void 0)&&C.client.isDisconnected||(yield m.engine.client.sendLeave()),m.engine&&(yield m.engine.close()),m.handleDisconnect(g,pn.CLIENT_INITIATED),m.engine=void 0}finally{k()}}()})},this.onPageLeave=()=>R(this,void 0,void 0,function*(){this.log.info("Page leave detected, disconnecting",this.logContext),yield this.disconnect()}),this.startAudio=()=>R(this,void 0,void 0,function*(){const u=[],d=Dn();if(d&&d.os==="iOS"){const h="livekit-dummy-audio-el";let m=document.getElementById(h);if(!m){m=document.createElement("audio"),m.id=h,m.autoplay=!0,m.hidden=!0;const g=Dd();g.enabled=!0;const y=new MediaStream([g]);m.srcObject=y,document.addEventListener("visibilitychange",()=>{m&&(m.srcObject=document.hidden?null:y,document.hidden||(this.log.debug("page visible again, triggering startAudio to resume playback and update playback status",this.logContext),this.startAudio()))}),document.body.append(m),this.once(B.Disconnected,()=>{m==null||m.remove(),m=null})}u.push(m)}this.remoteParticipants.forEach(h=>{h.audioTrackPublications.forEach(m=>{m.track&&m.track.attachedElements.forEach(g=>{u.push(g)})})});try{yield Promise.all([this.acquireAudioContext(),...u.map(h=>(h.muted=!1,h.play()))]),this.handleAudioPlaybackStarted()}catch(h){throw this.handleAudioPlaybackFailed(h),h}}),this.startVideo=()=>R(this,void 0,void 0,function*(){const u=[];for(const d of this.remoteParticipants.values())d.videoTrackPublications.forEach(h=>{var m;(m=h.track)===null||m===void 0||m.attachedElements.forEach(g=>{u.includes(g)||u.push(g)})});yield Promise.all(u.map(d=>d.play())).then(()=>{this.handleVideoPlaybackStarted()}).catch(d=>{d.name==="NotAllowedError"?this.handleVideoPlaybackFailed():this.log.warn("Resuming video playback failed, make sure you call `startVideo` directly in a user gesture handler",this.logContext)})}),this.handleRestarting=()=>{this.clearConnectionReconcile(),this.isResuming=!1;for(const u of this.remoteParticipants.values())this.handleParticipantDisconnected(u.identity,u);this.setAndEmitConnectionState(Te.Reconnecting)&&this.emit(B.Reconnecting)},this.handleSignalRestarted=u=>R(this,void 0,void 0,function*(){this.log.debug("signal reconnected to server, region ".concat(u.serverRegion),Object.assign(Object.assign({},this.logContext),{region:u.serverRegion})),this.bufferedEvents=[],this.applyJoinResponse(u);try{yield this.localParticipant.republishAllTracks(void 0,!0)}catch(d){this.log.error("error trying to re-publish tracks after reconnection",Object.assign(Object.assign({},this.logContext),{error:d}))}try{yield this.engine.waitForRestarted(),this.log.debug("fully reconnected to server",Object.assign(Object.assign({},this.logContext),{region:u.serverRegion}))}catch{return}this.setAndEmitConnectionState(Te.Connected),this.emit(B.Reconnected),this.registerConnectionReconcile(),this.emitBufferedEvents()}),this.handleParticipantUpdates=u=>{u.forEach(d=>{var h;if(d.identity===this.localParticipant.identity){this.localParticipant.updateInfo(d);return}d.identity===""&&(d.identity=(h=this.sidToIdentity.get(d.sid))!==null&&h!==void 0?h:"");let m=this.remoteParticipants.get(d.identity);d.state===Hd.DISCONNECTED?this.handleParticipantDisconnected(d.identity,m):m=this.getOrCreateParticipant(d.identity,d)})},this.handleActiveSpeakersUpdate=u=>{const d=[],h={};u.forEach(m=>{if(h[m.sid]=!0,m.sid===this.localParticipant.sid)this.localParticipant.audioLevel=m.level,this.localParticipant.setIsSpeaking(!0),d.push(this.localParticipant);else{const g=this.getRemoteParticipantBySid(m.sid);g&&(g.audioLevel=m.level,g.setIsSpeaking(!0),d.push(g))}}),h[this.localParticipant.sid]||(this.localParticipant.audioLevel=0,this.localParticipant.setIsSpeaking(!1)),this.remoteParticipants.forEach(m=>{h[m.sid]||(m.audioLevel=0,m.setIsSpeaking(!1))}),this.activeSpeakers=d,this.emitWhenConnected(B.ActiveSpeakersChanged,d)},this.handleSpeakersChanged=u=>{const d=new Map;this.activeSpeakers.forEach(m=>{const g=this.remoteParticipants.get(m.identity);g&&g.sid!==m.sid||d.set(m.sid,m)}),u.forEach(m=>{let g=this.getRemoteParticipantBySid(m.sid);m.sid===this.localParticipant.sid&&(g=this.localParticipant),g&&(g.audioLevel=m.level,g.setIsSpeaking(m.active),m.active?d.set(m.sid,g):d.delete(m.sid))});const h=Array.from(d.values());h.sort((m,g)=>g.audioLevel-m.audioLevel),this.activeSpeakers=h,this.emitWhenConnected(B.ActiveSpeakersChanged,h)},this.handleStreamStateUpdate=u=>{u.streamStates.forEach(d=>{const h=this.getRemoteParticipantBySid(d.participantSid);if(!h)return;const m=h.getTrackPublicationBySid(d.trackSid);if(!m||!m.track)return;const g=j.streamStateFromProto(d.state);g!==m.track.streamState&&(m.track.streamState=g,h.emit(F.TrackStreamStateChanged,m,m.track.streamState),this.emitWhenConnected(B.TrackStreamStateChanged,m,m.track.streamState,h))})},this.handleSubscriptionPermissionUpdate=u=>{const d=this.getRemoteParticipantBySid(u.participantSid);if(!d)return;const h=d.getTrackPublicationBySid(u.trackSid);h&&h.setAllowed(u.allowed)},this.handleSubscriptionError=u=>{const d=Array.from(this.remoteParticipants.values()).find(m=>m.trackPublications.has(u.trackSid));if(!d)return;const h=d.getTrackPublicationBySid(u.trackSid);h&&h.setSubscriptionError(u.err)},this.handleDataPacket=u=>{const d=this.remoteParticipants.get(u.participantIdentity);if(u.value.case==="user")this.handleUserPacket(d,u.value.value,u.kind);else if(u.value.case==="transcription")this.handleTranscription(d,u.value.value);else if(u.value.case==="sipDtmf")this.handleSipDtmf(d,u.value.value);else if(u.value.case==="chatMessage")this.handleChatMessage(d,u.value.value);else if(u.value.case==="metrics")this.handleMetrics(u.value.value,d);else if(u.value.case==="streamHeader")this.handleStreamHeader(u.value.value,u.participantIdentity);else if(u.value.case==="streamChunk")this.handleStreamChunk(u.value.value);else if(u.value.case==="streamTrailer")this.handleStreamTrailer(u.value.value);else if(u.value.case==="rpcRequest"){const h=u.value.value;this.handleIncomingRpcRequest(u.participantIdentity,h.id,h.method,h.payload,h.responseTimeoutMs,h.version)}},this.handleUserPacket=(u,d,h)=>{this.emit(B.DataReceived,d.payload,u,h,d.topic),u==null||u.emit(F.DataReceived,d.payload,h)},this.handleSipDtmf=(u,d)=>{this.emit(B.SipDTMFReceived,d,u),u==null||u.emit(F.SipDTMFReceived,d)},this.bufferedSegments=new Map,this.handleTranscription=(u,d)=>{const h=d.transcribedParticipantIdentity===this.localParticipant.identity?this.localParticipant:this.getParticipantByIdentity(d.transcribedParticipantIdentity),m=h==null?void 0:h.trackPublications.get(d.trackId),g=JE(d,this.transcriptionReceivedTimes);m==null||m.emit(W.TranscriptionReceived,g),h==null||h.emit(F.TranscriptionReceived,g,m),this.emit(B.TranscriptionReceived,g,h,m)},this.handleChatMessage=(u,d)=>{const h=WE(d);this.emit(B.ChatMessage,h,u)},this.handleMetrics=(u,d)=>{this.emit(B.MetricsReceived,u,d)},this.handleAudioPlaybackStarted=()=>{this.canPlaybackAudio||(this.audioEnabled=!0,this.emit(B.AudioPlaybackStatusChanged,!0))},this.handleAudioPlaybackFailed=u=>{this.log.warn("could not playback audio",Object.assign(Object.assign({},this.logContext),{error:u})),this.canPlaybackAudio&&(this.audioEnabled=!1,this.emit(B.AudioPlaybackStatusChanged,!1))},this.handleVideoPlaybackStarted=()=>{this.isVideoPlaybackBlocked&&(this.isVideoPlaybackBlocked=!1,this.emit(B.VideoPlaybackStatusChanged,!0))},this.handleVideoPlaybackFailed=()=>{this.isVideoPlaybackBlocked||(this.isVideoPlaybackBlocked=!0,this.emit(B.VideoPlaybackStatusChanged,!1))},this.handleDeviceChange=()=>R(this,void 0,void 0,function*(){var u,d;const h=gt.getInstance().previousDevices,m=yield gt.getInstance().getDevices(void 0,!1),g=Dn();if((g==null?void 0:g.name)==="Chrome"&&g.os!=="iOS")for(let b of m){const T=h.find(C=>C.deviceId===b.deviceId);T&&T.label!==""&&T.kind===b.kind&&T.label!==b.label&&this.getActiveDevice(b.kind)==="default"&&this.emit(B.ActiveDeviceChanged,b.kind,b.deviceId)}const y=["audiooutput","audioinput","videoinput"];for(let b of y){const T=m.filter(k=>k.kind===b),C=this.getActiveDevice(b);if(C===((u=h.filter(k=>k.kind===b)[0])===null||u===void 0?void 0:u.deviceId)&&T.length>0&&((d=T[0])===null||d===void 0?void 0:d.deviceId)!==C){yield this.switchActiveDevice(b,T[0].deviceId);continue}b==="audioinput"&&!Bi()||b==="videoinput"||T.length>0&&!T.find(k=>k.deviceId===this.getActiveDevice(b))&&(yield this.switchActiveDevice(b,T[0].deviceId))}this.emit(B.MediaDevicesChanged)}),this.handleRoomUpdate=u=>{const d=this.roomInfo;this.roomInfo=u,d&&d.metadata!==u.metadata&&this.emitWhenConnected(B.RoomMetadataChanged,u.metadata),(d==null?void 0:d.activeRecording)!==u.activeRecording&&this.emitWhenConnected(B.RecordingStatusChanged,u.activeRecording)},this.handleConnectionQualityUpdate=u=>{u.updates.forEach(d=>{if(d.participantSid===this.localParticipant.sid){this.localParticipant.setConnectionQuality(d.quality);return}const h=this.getRemoteParticipantBySid(d.participantSid);h&&h.setConnectionQuality(d.quality)})},this.onLocalParticipantMetadataChanged=u=>{this.emit(B.ParticipantMetadataChanged,u,this.localParticipant)},this.onLocalParticipantNameChanged=u=>{this.emit(B.ParticipantNameChanged,u,this.localParticipant)},this.onLocalAttributesChanged=u=>{this.emit(B.ParticipantAttributesChanged,u,this.localParticipant)},this.onLocalTrackMuted=u=>{this.emit(B.TrackMuted,u,this.localParticipant)},this.onLocalTrackUnmuted=u=>{this.emit(B.TrackUnmuted,u,this.localParticipant)},this.onTrackProcessorUpdate=u=>{var d;(d=u==null?void 0:u.onPublish)===null||d===void 0||d.call(u,this)},this.onLocalTrackPublished=u=>R(this,void 0,void 0,function*(){var d,h,m,g,y,b;(d=u.track)===null||d===void 0||d.on(W.TrackProcessorUpdate,this.onTrackProcessorUpdate),(h=u.track)===null||h===void 0||h.on(W.Restarted,this.onLocalTrackRestarted),(y=(g=(m=u.track)===null||m===void 0?void 0:m.getProcessor())===null||g===void 0?void 0:g.onPublish)===null||y===void 0||y.call(g,this),this.emit(B.LocalTrackPublished,u,this.localParticipant),ha(u.track)&&(yield u.track.checkForSilence())&&this.emit(B.LocalAudioSilenceDetected,u);const T=yield(b=u.track)===null||b===void 0?void 0:b.getDeviceId(!1),C=jv(u.source);C&&T&&T!==this.localParticipant.activeDeviceMap.get(C)&&(this.localParticipant.activeDeviceMap.set(C,T),this.emit(B.ActiveDeviceChanged,C,T))}),this.onLocalTrackUnpublished=u=>{var d,h;(d=u.track)===null||d===void 0||d.off(W.TrackProcessorUpdate,this.onTrackProcessorUpdate),(h=u.track)===null||h===void 0||h.off(W.Restarted,this.onLocalTrackRestarted),this.emit(B.LocalTrackUnpublished,u,this.localParticipant)},this.onLocalTrackRestarted=u=>R(this,void 0,void 0,function*(){const d=yield u.getDeviceId(!1),h=jv(u.source);h&&d&&d!==this.localParticipant.activeDeviceMap.get(h)&&(this.log.debug("local track restarted, setting ".concat(h," ").concat(d," active"),this.logContext),this.localParticipant.activeDeviceMap.set(h,d),this.emit(B.ActiveDeviceChanged,h,d))}),this.onLocalConnectionQualityChanged=u=>{this.emit(B.ConnectionQualityChanged,u,this.localParticipant)},this.onMediaDevicesError=u=>{this.emit(B.MediaDevicesError,u)},this.onLocalParticipantPermissionsChanged=u=>{this.emit(B.ParticipantPermissionsChanged,u,this.localParticipant)},this.onLocalChatMessageSent=u=>{this.emit(B.ChatMessage,u,this.localParticipant)},this.setMaxListeners(100),this.remoteParticipants=new Map,this.sidToIdentity=new Map,this.options=Object.assign(Object.assign({},b1),e),this.log=ei((r=this.options.loggerName)!==null&&r!==void 0?r:gn.Room),this.transcriptionReceivedTimes=new Map,this.options.audioCaptureDefaults=Object.assign(Object.assign({},Fy),e==null?void 0:e.audioCaptureDefaults),this.options.videoCaptureDefaults=Object.assign(Object.assign({},Yy),e==null?void 0:e.videoCaptureDefaults),this.options.publishDefaults=Object.assign(Object.assign({},y1),e==null?void 0:e.publishDefaults),this.maybeCreateEngine(),this.disconnectLock=new Ht,this.localParticipant=new Y1("","",this.engine,this.options,this.rpcHandlers),this.options.videoCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("videoinput",Ii(this.options.videoCaptureDefaults.deviceId)),this.options.audioCaptureDefaults.deviceId&&this.localParticipant.activeDeviceMap.set("audioinput",Ii(this.options.audioCaptureDefaults.deviceId)),!((o=this.options.audioOutput)===null||o===void 0)&&o.deviceId&&this.switchActiveDevice("audiooutput",Ii(this.options.audioOutput.deviceId)).catch(u=>this.log.warn("Could not set audio output: ".concat(u.message),this.logContext)),this.options.e2ee&&this.setupE2EE(),xt()){const u=new AbortController;(l=navigator.mediaDevices)===null||l===void 0||l.addEventListener("devicechange",this.handleDeviceChange,{signal:u.signal}),ni.cleanupRegistry&&ni.cleanupRegistry.register(this,()=>{u.abort()})}}registerTextStreamHandler(e,n){if(this.textStreamHandlers.has(e))throw new TypeError('A text stream handler for topic "'.concat(e,'" has already been set.'));this.textStreamHandlers.set(e,n)}unregisterTextStreamHandler(e){this.textStreamHandlers.delete(e)}registerByteStreamHandler(e,n){if(this.byteStreamHandlers.has(e))throw new TypeError('A byte stream handler for topic "'.concat(e,'" has already been set.'));this.byteStreamHandlers.set(e,n)}unregisterByteStreamHandler(e){this.byteStreamHandlers.delete(e)}registerRpcMethod(e,n){if(this.rpcHandlers.has(e))throw Error("RPC handler already registered for method ".concat(e,", unregisterRpcMethod before trying to register again"));this.rpcHandlers.set(e,n)}unregisterRpcMethod(e){this.rpcHandlers.delete(e)}handleIncomingRpcRequest(e,n,r,o,l,u){return R(this,void 0,void 0,function*(){if(yield this.engine.publishRpcAck(e,n),u!==1){yield this.engine.publishRpcResponse(e,n,null,et.builtIn("UNSUPPORTED_VERSION"));return}const d=this.rpcHandlers.get(r);if(!d){yield this.engine.publishRpcResponse(e,n,null,et.builtIn("UNSUPPORTED_METHOD"));return}let h=null,m=null;try{const g=yield d({requestId:n,callerIdentity:e,payload:o,responseTimeout:l});Zf(g)>Ky?(h=et.builtIn("RESPONSE_PAYLOAD_TOO_LARGE"),console.warn("RPC Response payload too large for ".concat(r))):m=g}catch(g){g instanceof et?h=g:(console.warn("Uncaught error returned by RPC handler for ".concat(r,". Returning APPLICATION_ERROR instead."),g),h=et.builtIn("APPLICATION_ERROR"))}yield this.engine.publishRpcResponse(e,n,m,h)})}setE2EEEnabled(e){return R(this,void 0,void 0,function*(){if(this.e2eeManager)yield Promise.all([this.localParticipant.setE2EEEnabled(e)]),this.localParticipant.identity!==""&&this.e2eeManager.setParticipantCryptorEnabled(e,this.localParticipant.identity);else throw Error("e2ee not configured, please set e2ee settings within the room options")})}setupE2EE(){var e;this.options.e2ee&&("e2eeManager"in this.options.e2ee?this.e2eeManager=this.options.e2ee.e2eeManager:this.e2eeManager=new o1(this.options.e2ee),this.e2eeManager.on(Ui.ParticipantEncryptionStatusChanged,(n,r)=>{e1(r)&&(this.isE2EEEnabled=n),this.emit(B.ParticipantEncryptionStatusChanged,n,r)}),this.e2eeManager.on(Ui.EncryptionError,n=>this.emit(B.EncryptionError,n)),(e=this.e2eeManager)===null||e===void 0||e.setup(this))}get logContext(){var e;return{room:this.name,roomID:(e=this.roomInfo)===null||e===void 0?void 0:e.sid,participant:this.localParticipant.identity,pID:this.localParticipant.sid}}get isRecording(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.activeRecording)!==null&&n!==void 0?n:!1}getSid(){return R(this,void 0,void 0,function*(){return this.state===Te.Disconnected?"":this.roomInfo&&this.roomInfo.sid!==""?this.roomInfo.sid:new Promise((e,n)=>{const r=o=>{o.sid!==""&&(this.engine.off(ne.RoomUpdate,r),e(o.sid))};this.engine.on(ne.RoomUpdate,r),this.once(B.Disconnected,()=>{this.engine.off(ne.RoomUpdate,r),n("Room disconnected before room server id was available")})})})}get name(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.name)!==null&&n!==void 0?n:""}get metadata(){var e;return(e=this.roomInfo)===null||e===void 0?void 0:e.metadata}get numParticipants(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.numParticipants)!==null&&n!==void 0?n:0}get numPublishers(){var e,n;return(n=(e=this.roomInfo)===null||e===void 0?void 0:e.numPublishers)!==null&&n!==void 0?n:0}maybeCreateEngine(){this.engine&&!this.engine.isClosed||(this.engine=new N1(this.options),this.engine.on(ne.ParticipantUpdate,this.handleParticipantUpdates).on(ne.RoomUpdate,this.handleRoomUpdate).on(ne.SpeakersChanged,this.handleSpeakersChanged).on(ne.StreamStateChanged,this.handleStreamStateUpdate).on(ne.ConnectionQualityUpdate,this.handleConnectionQualityUpdate).on(ne.SubscriptionError,this.handleSubscriptionError).on(ne.SubscriptionPermissionUpdate,this.handleSubscriptionPermissionUpdate).on(ne.MediaTrackAdded,(e,n,r)=>{this.onTrackAdded(e,n,r)}).on(ne.Disconnected,e=>{this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,e)}).on(ne.ActiveSpeakersUpdate,this.handleActiveSpeakersUpdate).on(ne.DataPacketReceived,this.handleDataPacket).on(ne.Resuming,()=>{this.clearConnectionReconcile(),this.isResuming=!0,this.log.info("Resuming signal connection",this.logContext),this.setAndEmitConnectionState(Te.SignalReconnecting)&&this.emit(B.SignalReconnecting)}).on(ne.Resumed,()=>{this.registerConnectionReconcile(),this.isResuming=!1,this.log.info("Resumed signal connection",this.logContext),this.updateSubscriptions(),this.emitBufferedEvents(),this.setAndEmitConnectionState(Te.Connected)&&this.emit(B.Reconnected)}).on(ne.SignalResumed,()=>{this.bufferedEvents=[],(this.state===Te.Reconnecting||this.isResuming)&&this.sendSyncState()}).on(ne.Restarting,this.handleRestarting).on(ne.SignalRestarted,this.handleSignalRestarted).on(ne.Offline,()=>{this.setAndEmitConnectionState(Te.Reconnecting)&&this.emit(B.Reconnecting)}).on(ne.DCBufferStatusChanged,(e,n)=>{this.emit(B.DCBufferStatusChanged,e,n)}).on(ne.LocalTrackSubscribed,e=>{const n=this.localParticipant.getTrackPublications().find(r=>{let{trackSid:o}=r;return o===e});if(!n){this.log.warn("could not find local track subscription for subscribed event",this.logContext);return}this.localParticipant.emit(F.LocalTrackSubscribed,n),this.emitWhenConnected(B.LocalTrackSubscribed,n,this.localParticipant)}),this.localParticipant&&this.localParticipant.setupEngine(this.engine),this.e2eeManager&&this.e2eeManager.setupEngine(this.engine))}static getLocalDevices(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return gt.getInstance().getDevices(e,n)}prepareConnection(e,n){return R(this,void 0,void 0,function*(){if(this.state===Te.Disconnected){this.log.debug("prepareConnection to ".concat(e),this.logContext);try{if(hf(new URL(e))&&n){this.regionUrlProvider=new bf(e,n);const r=yield this.regionUrlProvider.getNextBestRegionUrl();r&&this.state===Te.Disconnected&&(this.regionUrl=r,yield fetch(Lv(r),{method:"HEAD"}),this.log.debug("prepared connection to ".concat(r),this.logContext))}else yield fetch(Lv(e),{method:"HEAD"})}catch(r){this.log.warn("could not prepare connection",Object.assign(Object.assign({},this.logContext),{error:r}))}}})}getParticipantByIdentity(e){return this.localParticipant.identity===e?this.localParticipant:this.remoteParticipants.get(e)}clearConnectionFutures(){this.connectFuture=void 0}simulateScenario(e,n){return R(this,void 0,void 0,function*(){let r=()=>{},o;switch(e){case"signal-reconnect":yield this.engine.client.handleOnClose("simulate disconnect");break;case"speaker":o=new _n({scenario:{case:"speakerUpdate",value:3}});break;case"node-failure":o=new _n({scenario:{case:"nodeFailure",value:!0}});break;case"server-leave":o=new _n({scenario:{case:"serverLeave",value:!0}});break;case"migration":o=new _n({scenario:{case:"migration",value:!0}});break;case"resume-reconnect":this.engine.failNext(),yield this.engine.client.handleOnClose("simulate resume-disconnect");break;case"disconnect-signal-on-resume":r=()=>R(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),o=new _n({scenario:{case:"disconnectSignalOnResume",value:!0}});break;case"disconnect-signal-on-resume-no-messages":r=()=>R(this,void 0,void 0,function*(){yield this.engine.client.handleOnClose("simulate resume-disconnect")}),o=new _n({scenario:{case:"disconnectSignalOnResumeNoMessages",value:!0}});break;case"full-reconnect":this.engine.fullReconnectOnNext=!0,yield this.engine.client.handleOnClose("simulate full-reconnect");break;case"force-tcp":case"force-tls":o=new _n({scenario:{case:"switchCandidateProtocol",value:e==="force-tls"?2:1}}),r=()=>R(this,void 0,void 0,function*(){const l=this.engine.client.onLeave;l&&l(new Yc({reason:pn.CLIENT_INITIATED,action:ur.RECONNECT}))});break;case"subscriber-bandwidth":if(n===void 0||typeof n!="number")throw new Error("subscriber-bandwidth requires a number as argument");o=new _n({scenario:{case:"subscriberBandwidth",value:fa(n)}});break;case"leave-full-reconnect":o=new _n({scenario:{case:"leaveRequestFullReconnect",value:!0}})}o&&(yield this.engine.client.sendSimulateScenario(o),yield r())})}get canPlaybackAudio(){return this.audioEnabled}get canPlaybackVideo(){return!this.isVideoPlaybackBlocked}getActiveDevice(e){return this.localParticipant.activeDeviceMap.get(e)}switchActiveDevice(e,n){return R(this,arguments,void 0,function(r,o){var l=this;let u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return function*(){var d,h,m,g,y,b,T,C;let k=!0,w=!1;const O=u?{exact:o}:o;if(r==="audioinput"){w=l.localParticipant.audioTrackPublications.size===0;const V=(d=l.getActiveDevice(r))!==null&&d!==void 0?d:l.options.audioCaptureDefaults.deviceId;l.options.audioCaptureDefaults.deviceId=O;const Q=Array.from(l.localParticipant.audioTrackPublications.values()).filter(U=>U.source===j.Source.Microphone);try{k=(yield Promise.all(Q.map(U=>{var _;return(_=U.audioTrack)===null||_===void 0?void 0:_.setDeviceId(O)}))).every(U=>U===!0)}catch(U){throw l.options.audioCaptureDefaults.deviceId=V,U}}else if(r==="videoinput"){w=l.localParticipant.videoTrackPublications.size===0;const V=(h=l.getActiveDevice(r))!==null&&h!==void 0?h:l.options.videoCaptureDefaults.deviceId;l.options.videoCaptureDefaults.deviceId=O;const Q=Array.from(l.localParticipant.videoTrackPublications.values()).filter(U=>U.source===j.Source.Camera);try{k=(yield Promise.all(Q.map(U=>{var _;return(_=U.videoTrack)===null||_===void 0?void 0:_.setDeviceId(O)}))).every(U=>U===!0)}catch(U){throw l.options.videoCaptureDefaults.deviceId=V,U}}else if(r==="audiooutput"){if(!ff()&&!l.options.webAudioMix||l.options.webAudioMix&&l.audioContext&&!("setSinkId"in l.audioContext))throw new Error("cannot switch audio output, setSinkId not supported");l.options.webAudioMix&&(o=(m=yield gt.getInstance().normalizeDeviceId("audiooutput",o))!==null&&m!==void 0?m:""),(g=(C=l.options).audioOutput)!==null&&g!==void 0||(C.audioOutput={});const V=(y=l.getActiveDevice(r))!==null&&y!==void 0?y:l.options.audioOutput.deviceId;l.options.audioOutput.deviceId=o;try{l.options.webAudioMix&&((b=l.audioContext)===null||b===void 0||b.setSinkId(o)),yield Promise.all(Array.from(l.remoteParticipants.values()).map(Q=>Q.setAudioOutput({deviceId:o})))}catch(Q){throw l.options.audioOutput.deviceId=V,Q}}return(w||r==="audiooutput")&&(l.localParticipant.activeDeviceMap.set(r,r==="audiooutput"&&((T=l.options.audioOutput)===null||T===void 0?void 0:T.deviceId)||o),l.emit(B.ActiveDeviceChanged,r,o)),k}()})}setupLocalParticipantEvents(){this.localParticipant.on(F.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).on(F.ParticipantNameChanged,this.onLocalParticipantNameChanged).on(F.AttributesChanged,this.onLocalAttributesChanged).on(F.TrackMuted,this.onLocalTrackMuted).on(F.TrackUnmuted,this.onLocalTrackUnmuted).on(F.LocalTrackPublished,this.onLocalTrackPublished).on(F.LocalTrackUnpublished,this.onLocalTrackUnpublished).on(F.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).on(F.MediaDevicesError,this.onMediaDevicesError).on(F.AudioStreamAcquired,this.startAudio).on(F.ChatMessage,this.onLocalChatMessageSent).on(F.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged)}recreateEngine(){var e;(e=this.engine)===null||e===void 0||e.close(),this.engine=void 0,this.isResuming=!1,this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.bufferedEvents=[],this.maybeCreateEngine()}onTrackAdded(e,n,r){if(this.state===Te.Connecting||this.state===Te.Reconnecting){const g=()=>{this.onTrackAdded(e,n,r),y()},y=()=>{this.off(B.Reconnected,g),this.off(B.Connected,g),this.off(B.Disconnected,y)};this.once(B.Reconnected,g),this.once(B.Connected,g),this.once(B.Disconnected,y);return}if(this.state===Te.Disconnected){this.log.warn("skipping incoming track after Room disconnected",this.logContext);return}const o=BE(n.id),l=o[0];let u=o[1],d=e.id;if(u&&u.startsWith("TR")&&(d=u),l===this.localParticipant.sid){this.log.warn("tried to create RemoteParticipant for local participant",this.logContext);return}const h=Array.from(this.remoteParticipants.values()).find(g=>g.sid===l);if(!h){this.log.error("Tried to add a track for a participant, that's not present. Sid: ".concat(l),this.logContext);return}let m;this.options.adaptiveStream&&(typeof this.options.adaptiveStream=="object"?m=this.options.adaptiveStream:m={}),h.addSubscribedMediaTrack(e,d,n,r,m)}handleDisconnect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,n=arguments.length>1?arguments[1]:void 0;var r;if(this.clearConnectionReconcile(),this.isResuming=!1,this.bufferedEvents=[],this.transcriptionReceivedTimes.clear(),this.state!==Te.Disconnected){this.regionUrl=void 0;try{this.remoteParticipants.forEach(o=>{o.trackPublications.forEach(l=>{o.unpublishTrack(l.trackSid)})}),this.localParticipant.trackPublications.forEach(o=>{var l,u,d;o.track&&this.localParticipant.unpublishTrack(o.track,e),e?((l=o.track)===null||l===void 0||l.detach(),(u=o.track)===null||u===void 0||u.stop()):(d=o.track)===null||d===void 0||d.stopMonitor()}),this.localParticipant.off(F.ParticipantMetadataChanged,this.onLocalParticipantMetadataChanged).off(F.ParticipantNameChanged,this.onLocalParticipantNameChanged).off(F.AttributesChanged,this.onLocalAttributesChanged).off(F.TrackMuted,this.onLocalTrackMuted).off(F.TrackUnmuted,this.onLocalTrackUnmuted).off(F.LocalTrackPublished,this.onLocalTrackPublished).off(F.LocalTrackUnpublished,this.onLocalTrackUnpublished).off(F.ConnectionQualityChanged,this.onLocalConnectionQualityChanged).off(F.MediaDevicesError,this.onMediaDevicesError).off(F.AudioStreamAcquired,this.startAudio).off(F.ChatMessage,this.onLocalChatMessageSent).off(F.ParticipantPermissionsChanged,this.onLocalParticipantPermissionsChanged),this.localParticipant.trackPublications.clear(),this.localParticipant.videoTrackPublications.clear(),this.localParticipant.audioTrackPublications.clear(),this.remoteParticipants.clear(),this.sidToIdentity.clear(),this.activeSpeakers=[],this.audioContext&&typeof this.options.webAudioMix=="boolean"&&(this.audioContext.close(),this.audioContext=void 0),xt()&&(window.removeEventListener("beforeunload",this.onPageLeave),window.removeEventListener("pagehide",this.onPageLeave),window.removeEventListener("freeze",this.onPageLeave),(r=navigator.mediaDevices)===null||r===void 0||r.removeEventListener("devicechange",this.handleDeviceChange))}finally{this.setAndEmitConnectionState(Te.Disconnected),this.emit(B.Disconnected,n)}}}handleParticipantDisconnected(e,n){var r;this.remoteParticipants.delete(e),n&&(n.trackPublications.forEach(o=>{n.unpublishTrack(o.trackSid,!0)}),this.emit(B.ParticipantDisconnected,n),(r=this.localParticipant)===null||r===void 0||r.handleParticipantDisconnected(n.identity))}handleStreamHeader(e,n){return R(this,void 0,void 0,function*(){var r;if(e.contentHeader.case==="byteHeader"){const o=this.byteStreamHandlers.get(e.topic);if(!o){this.log.debug("ignoring incoming byte stream due to no handler for topic",e.topic);return}let l;const u={id:e.streamId,name:(r=e.contentHeader.value.name)!==null&&r!==void 0?r:"unknown",mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Oc(e.timestamp),attributes:e.attributes},d=new ReadableStream({start:h=>{l=h,this.byteStreamControllers.set(e.streamId,{info:u,controller:l,startTime:Date.now()})}});o(new j1(u,d,Oc(e.totalLength)),{identity:n})}else if(e.contentHeader.case==="textHeader"){const o=this.textStreamHandlers.get(e.topic);if(!o){this.log.debug("ignoring incoming text stream due to no handler for topic",e.topic);return}let l;const u={id:e.streamId,mimeType:e.mimeType,size:e.totalLength?Number(e.totalLength):void 0,topic:e.topic,timestamp:Number(e.timestamp),attributes:e.attributes},d=new ReadableStream({start:h=>{l=h,this.textStreamControllers.set(e.streamId,{info:u,controller:l,startTime:Date.now()})}});o(new B1(u,d,Oc(e.totalLength)),{identity:n})}})}handleStreamChunk(e){const n=this.byteStreamControllers.get(e.streamId);n&&e.content.length>0&&n.controller.enqueue(e);const r=this.textStreamControllers.get(e.streamId);r&&e.content.length>0&&r.controller.enqueue(e)}handleStreamTrailer(e){const n=this.textStreamControllers.get(e.streamId);n&&(n.info.attributes=Object.assign(Object.assign({},n.info.attributes),e.attributes),n.controller.close(),this.textStreamControllers.delete(e.streamId));const r=this.byteStreamControllers.get(e.streamId);r&&(r.info.attributes=Object.assign(Object.assign({},r.info.attributes),e.attributes),r.controller.close(),this.byteStreamControllers.delete(e.streamId))}acquireAudioContext(){return R(this,void 0,void 0,function*(){var e,n;if(typeof this.options.webAudioMix!="boolean"&&this.options.webAudioMix.audioContext?this.audioContext=this.options.webAudioMix.audioContext:(!this.audioContext||this.audioContext.state==="closed")&&(this.audioContext=(e=Gf())!==null&&e!==void 0?e:void 0),this.options.webAudioMix&&this.remoteParticipants.forEach(o=>o.setAudioContext(this.audioContext)),this.localParticipant.setAudioContext(this.audioContext),this.audioContext&&this.audioContext.state==="suspended")try{yield Promise.race([this.audioContext.resume(),Nt(200)])}catch(o){this.log.warn("Could not resume audio context",Object.assign(Object.assign({},this.logContext),{error:o}))}const r=((n=this.audioContext)===null||n===void 0?void 0:n.state)==="running";r!==this.canPlaybackAudio&&(this.audioEnabled=r,this.emit(B.AudioPlaybackStatusChanged,r))})}createParticipant(e,n){var r;let o;return n?o=Ic.fromParticipantInfo(this.engine.client,n,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}):o=new Ic(this.engine.client,"",e,void 0,void 0,void 0,{loggerContextCb:()=>this.logContext,loggerName:this.options.loggerName}),this.options.webAudioMix&&o.setAudioContext(this.audioContext),!((r=this.options.audioOutput)===null||r===void 0)&&r.deviceId&&o.setAudioOutput(this.options.audioOutput).catch(l=>this.log.warn("Could not set audio output: ".concat(l.message),this.logContext)),o}getOrCreateParticipant(e,n){if(this.remoteParticipants.has(e)){const o=this.remoteParticipants.get(e);return n&&o.updateInfo(n)&&this.sidToIdentity.set(n.sid,n.identity),o}const r=this.createParticipant(e,n);return this.remoteParticipants.set(e,r),this.sidToIdentity.set(n.sid,n.identity),this.emitWhenConnected(B.ParticipantConnected,r),r.on(F.TrackPublished,o=>{this.emitWhenConnected(B.TrackPublished,o,r)}).on(F.TrackSubscribed,(o,l)=>{o.kind===j.Kind.Audio?(o.on(W.AudioPlaybackStarted,this.handleAudioPlaybackStarted),o.on(W.AudioPlaybackFailed,this.handleAudioPlaybackFailed)):o.kind===j.Kind.Video&&(o.on(W.VideoPlaybackFailed,this.handleVideoPlaybackFailed),o.on(W.VideoPlaybackStarted,this.handleVideoPlaybackStarted)),this.emit(B.TrackSubscribed,o,l,r)}).on(F.TrackUnpublished,o=>{this.emit(B.TrackUnpublished,o,r)}).on(F.TrackUnsubscribed,(o,l)=>{this.emit(B.TrackUnsubscribed,o,l,r)}).on(F.TrackMuted,o=>{this.emitWhenConnected(B.TrackMuted,o,r)}).on(F.TrackUnmuted,o=>{this.emitWhenConnected(B.TrackUnmuted,o,r)}).on(F.ParticipantMetadataChanged,o=>{this.emitWhenConnected(B.ParticipantMetadataChanged,o,r)}).on(F.ParticipantNameChanged,o=>{this.emitWhenConnected(B.ParticipantNameChanged,o,r)}).on(F.AttributesChanged,o=>{this.emitWhenConnected(B.ParticipantAttributesChanged,o,r)}).on(F.ConnectionQualityChanged,o=>{this.emitWhenConnected(B.ConnectionQualityChanged,o,r)}).on(F.ParticipantPermissionsChanged,o=>{this.emitWhenConnected(B.ParticipantPermissionsChanged,o,r)}).on(F.TrackSubscriptionStatusChanged,(o,l)=>{this.emitWhenConnected(B.TrackSubscriptionStatusChanged,o,l,r)}).on(F.TrackSubscriptionFailed,(o,l)=>{this.emit(B.TrackSubscriptionFailed,o,r,l)}).on(F.TrackSubscriptionPermissionChanged,(o,l)=>{this.emitWhenConnected(B.TrackSubscriptionPermissionChanged,o,l,r)}),n&&r.updateInfo(n),r}sendSyncState(){const e=Array.from(this.remoteParticipants.values()).reduce((r,o)=>(r.push(...o.getTrackPublications()),r),[]),n=this.localParticipant.getTrackPublications();this.engine.sendSyncState(e,n)}updateSubscriptions(){for(const e of this.remoteParticipants.values())for(const n of e.videoTrackPublications.values())n.isSubscribed&&$E(n)&&n.emitTrackUpdate()}getRemoteParticipantBySid(e){const n=this.sidToIdentity.get(e);if(n)return this.remoteParticipants.get(n)}registerConnectionReconcile(){this.clearConnectionReconcile();let e=0;this.connectionReconcileInterval=Tt.setInterval(()=>{!this.engine||this.engine.isClosed||!this.engine.verifyTransport()?(e++,this.log.warn("detected connection state mismatch",Object.assign(Object.assign({},this.logContext),{numFailures:e,engine:this.engine?{closed:this.engine.isClosed,transportsConnected:this.engine.verifyTransport()}:void 0})),e>=3&&(this.recreateEngine(),this.handleDisconnect(this.options.stopLocalTrackOnUnpublish,pn.STATE_MISMATCH))):e=0},K1)}clearConnectionReconcile(){this.connectionReconcileInterval&&Tt.clearInterval(this.connectionReconcileInterval)}setAndEmitConnectionState(e){return e===this.state?!1:(this.state=e,this.emit(B.ConnectionStateChanged,this.state),!0)}emitBufferedEvents(){this.bufferedEvents.forEach(e=>{let[n,r]=e;this.emit(n,...r)}),this.bufferedEvents=[]}emitWhenConnected(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];if(this.state===Te.Reconnecting||this.isResuming||!this.engine||this.engine.pendingReconnect)this.bufferedEvents.push([e,r]);else if(this.state===Te.Connected)return this.emit(e,...r);return!1}simulateParticipants(e){return R(this,void 0,void 0,function*(){var n,r;const o=Object.assign({audio:!0,video:!0,useRealTracks:!1},e.publish),l=Object.assign({count:9,audio:!1,video:!0,aspectRatios:[1.66,1.7,1.3]},e.participants);if(this.handleDisconnect(),this.roomInfo=new Uf({sid:"RM_SIMULATED",name:"simulated-room",emptyTimeout:0,maxParticipants:0,creationTime:Ge.parse(new Date().getTime()),metadata:"",numParticipants:1,numPublishers:1,turnPassword:"",enabledCodecs:[],activeRecording:!1}),this.localParticipant.updateInfo(new zs({identity:"simulated-local",name:"local-name"})),this.setupLocalParticipantEvents(),this.emit(B.SignalConnected),this.emit(B.Connected),this.setAndEmitConnectionState(Te.Connected),o.video){const u=new Tf(j.Kind.Video,new cr({source:ot.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:hn.AUDIO,name:"video-dummy"}),new Lc(o.useRealTracks?(yield window.navigator.mediaDevices.getUserMedia({video:!0})).getVideoTracks()[0]:Uv(160*((n=l.aspectRatios[0])!==null&&n!==void 0?n:1),160,!0,!0),void 0,!1,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(u),this.localParticipant.emit(F.LocalTrackPublished,u)}if(o.audio){const u=new Tf(j.Kind.Audio,new cr({source:ot.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:hn.AUDIO}),new Uc(o.useRealTracks?(yield navigator.mediaDevices.getUserMedia({audio:!0})).getAudioTracks()[0]:Dd(),void 0,!1,this.audioContext,{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext}),{loggerName:this.options.loggerName,loggerContextCb:()=>this.logContext});this.localParticipant.addTrackPublication(u),this.localParticipant.emit(F.LocalTrackPublished,u)}for(let u=0;u<l.count-1;u+=1){let d=new zs({sid:Math.floor(Math.random()*1e4).toString(),identity:"simulated-".concat(u),state:Hd.ACTIVE,tracks:[],joinedAt:Ge.parse(Date.now())});const h=this.getOrCreateParticipant(d.identity,d);if(l.video){const m=Uv(160*((r=l.aspectRatios[u%l.aspectRatios.length])!==null&&r!==void 0?r:1),160,!1,!0),g=new cr({source:ot.CAMERA,sid:Math.floor(Math.random()*1e4).toString(),type:hn.AUDIO});h.addSubscribedMediaTrack(m,g.sid,new MediaStream([m]),new RTCRtpReceiver),d.tracks=[...d.tracks,g]}if(l.audio){const m=Dd(),g=new cr({source:ot.MICROPHONE,sid:Math.floor(Math.random()*1e4).toString(),type:hn.AUDIO});h.addSubscribedMediaTrack(m,g.sid,new MediaStream([m]),new RTCRtpReceiver),d.tracks=[...d.tracks,g]}h.updateInfo(d)}})}emit(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];if(e!==B.ActiveSpeakersChanged){const l=ib(r).filter(u=>u!==void 0);this.log.debug("room event ".concat(e),Object.assign(Object.assign({},this.logContext),{event:e,args:l}))}return super.emit(e,...r)}}ni.cleanupRegistry=typeof FinalizationRegistry<"u"&&new FinalizationRegistry(a=>{a()});function ib(a){return a.map(e=>{if(e)return Array.isArray(e)?ib(e):typeof e=="object"?"logContext"in e?e.logContext:void 0:e})}var fn;(function(a){a[a.IDLE=0]="IDLE",a[a.RUNNING=1]="RUNNING",a[a.SKIPPED=2]="SKIPPED",a[a.SUCCESS=3]="SUCCESS",a[a.FAILED=4]="FAILED"})(fn||(fn={}));class Hi extends xn.EventEmitter{constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.status=fn.IDLE,this.logs=[],this.options={},this.url=e,this.token=n,this.name=this.constructor.name,this.room=new ni(r.roomOptions),this.connectOptions=r.connectOptions,this.options=r}run(e){return R(this,void 0,void 0,function*(){if(this.status!==fn.IDLE)throw Error("check is running already");this.setStatus(fn.RUNNING);try{yield this.perform()}catch(n){n instanceof Error&&(this.options.errorsAsWarnings?this.appendWarning(n.message):this.appendError(n.message))}return yield this.disconnect(),yield new Promise(n=>setTimeout(n,500)),this.status!==fn.SKIPPED&&this.setStatus(this.isSuccess()?fn.SUCCESS:fn.FAILED),e&&e(),this.getInfo()})}isSuccess(){return!this.logs.some(e=>e.level==="error")}connect(e){return R(this,void 0,void 0,function*(){return this.room.state===Te.Connected?this.room:(e||(e=this.url),yield this.room.connect(e,this.token,this.connectOptions),this.room)})}disconnect(){return R(this,void 0,void 0,function*(){this.room&&this.room.state!==Te.Disconnected&&(yield this.room.disconnect(),yield new Promise(e=>setTimeout(e,500)))})}skip(){this.setStatus(fn.SKIPPED)}switchProtocol(e){return R(this,void 0,void 0,function*(){let n=!1,r=!1;if(this.room.on(B.Reconnecting,()=>{n=!0}),this.room.once(B.Reconnected,()=>{r=!0}),this.room.simulateScenario("force-".concat(e)),yield new Promise(l=>setTimeout(l,1e3)),!n)return;const o=Date.now()+1e4;for(;Date.now()<o;){if(r)return;yield Nt(100)}throw new Error("Could not reconnect using ".concat(e," protocol after 10 seconds"))})}appendMessage(e){this.logs.push({level:"info",message:e}),this.emit("update",this.getInfo())}appendWarning(e){this.logs.push({level:"warning",message:e}),this.emit("update",this.getInfo())}appendError(e){this.logs.push({level:"error",message:e}),this.emit("update",this.getInfo())}setStatus(e){this.status=e,this.emit("update",this.getInfo())}get engine(){var e;return(e=this.room)===null||e===void 0?void 0:e.engine}getInfo(){return{logs:this.logs,name:this.name,status:this.status,description:this.description}}}class Q1 extends Hi{get description(){return"Cloud regions"}perform(){return R(this,void 0,void 0,function*(){const e=new bf(this.url,this.token);if(!e.isCloud()){this.skip();return}const n=[],r=new Set;for(let l=0;l<3;l++){const u=yield e.getNextBestRegionUrl();if(!u)break;if(r.has(u))continue;r.add(u);const d=yield this.checkCloudRegion(u);this.appendMessage("".concat(d.region," RTT: ").concat(d.rtt,"ms, duration: ").concat(d.duration,"ms")),n.push(d)}n.sort((l,u)=>(l.duration-u.duration)*.5+(l.rtt-u.rtt)*.5);const o=n[0];this.bestStats=o,this.appendMessage("best Cloud region: ".concat(o.region))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkCloudRegion(e){return R(this,void 0,void 0,function*(){var n,r;yield this.connect(e),this.options.protocol==="tcp"&&(yield this.switchProtocol("tcp"));const o=(n=this.room.serverInfo)===null||n===void 0?void 0:n.region;if(!o)throw new Error("Region not found");const l=yield this.room.localParticipant.streamText({topic:"test"}),u=1e3,h=1e6/u,m="A".repeat(u),g=Date.now();for(let C=0;C<h;C++)yield l.write(m);yield l.close();const y=Date.now(),b=yield(r=this.room.engine.pcManager)===null||r===void 0?void 0:r.publisher.getStats(),T={region:o,rtt:1e4,duration:y-g};return b==null||b.forEach(C=>{C.type==="candidate-pair"&&C.nominated&&(T.rtt=C.currentRoundTripTime*1e3)}),yield this.disconnect(),T})}}const jd=1e4;class X1 extends Hi{get description(){return"Connection via UDP vs TCP"}perform(){return R(this,void 0,void 0,function*(){const e=yield this.checkConnectionProtocol("udp"),n=yield this.checkConnectionProtocol("tcp");this.bestStats=e,e.qualityLimitationDurations.bandwidth-n.qualityLimitationDurations.bandwidth>.5||(e.packetsLost-n.packetsLost)/e.packetsSent>.01?(this.appendMessage("best connection quality via tcp"),this.bestStats=n):this.appendMessage("best connection quality via udp");const r=this.bestStats;this.appendMessage("upstream bitrate: ".concat((r.bitrateTotal/r.count/1e3/1e3).toFixed(2)," mbps")),this.appendMessage("RTT: ".concat((r.rttTotal/r.count*1e3).toFixed(2)," ms")),this.appendMessage("jitter: ".concat((r.jitterTotal/r.count*1e3).toFixed(2)," ms")),r.packetsLost>0&&this.appendWarning("packets lost: ".concat((r.packetsLost/r.packetsSent*100).toFixed(2),"%")),r.qualityLimitationDurations.bandwidth>1&&this.appendWarning("bandwidth limited ".concat((r.qualityLimitationDurations.bandwidth/(jd/1e3)*100).toFixed(2),"%")),r.qualityLimitationDurations.cpu>0&&this.appendWarning("cpu limited ".concat((r.qualityLimitationDurations.cpu/(jd/1e3)*100).toFixed(2),"%"))})}getInfo(){const e=super.getInfo();return e.data=this.bestStats,e}checkConnectionProtocol(e){return R(this,void 0,void 0,function*(){yield this.connect(),e==="tcp"?yield this.switchProtocol("tcp"):yield this.switchProtocol("udp");const n=document.createElement("canvas");n.width=1280,n.height=720;const r=n.getContext("2d");if(!r)throw new Error("Could not get canvas context");let o=0;const l=()=>{o=(o+1)%360,r.fillStyle="hsl(".concat(o,", 100%, 50%)"),r.fillRect(0,0,n.width,n.height),requestAnimationFrame(l)};l();const d=n.captureStream(30).getVideoTracks()[0],m=(yield this.room.localParticipant.publishTrack(d,{simulcast:!1,degradationPreference:"maintain-resolution",videoEncoding:{maxBitrate:2e6}})).track,g={protocol:e,packetsLost:0,packetsSent:0,qualityLimitationDurations:{},rttTotal:0,jitterTotal:0,bitrateTotal:0,count:0},y=setInterval(()=>R(this,void 0,void 0,function*(){const b=yield m.getRTCStatsReport();b==null||b.forEach(T=>{T.type==="outbound-rtp"?(g.packetsSent=T.packetsSent,g.qualityLimitationDurations=T.qualityLimitationDurations,g.bitrateTotal+=T.targetBitrate,g.count++):T.type==="remote-inbound-rtp"&&(g.packetsLost=T.packetsLost,g.rttTotal+=T.roundTripTime,g.jitterTotal+=T.jitter)})}),1e3);return yield new Promise(b=>setTimeout(b,jd)),clearInterval(y),d.stop(),n.remove(),yield this.disconnect(),g})}}function ab(a){return R(this,void 0,void 0,function*(){var e,n;a??(a={}),(e=a.audio)!==null&&e!==void 0||(a.audio={deviceId:"default"}),(n=a.video)!==null&&n!==void 0||(a.video={deviceId:"default"});const{audioProcessor:r,videoProcessor:o}=Ff(a),l=Hy(a,Fy,Yy),u=Qc(l),d=navigator.mediaDevices.getUserMedia(u);a.audio&&(gt.userMediaPromiseMap.set("audioinput",d),d.catch(()=>gt.userMediaPromiseMap.delete("audioinput"))),a.video&&(gt.userMediaPromiseMap.set("videoinput",d),d.catch(()=>gt.userMediaPromiseMap.delete("videoinput")));const h=yield d;return Promise.all(h.getTracks().map(m=>R(this,void 0,void 0,function*(){const g=m.kind==="audio";g?l.audio:l.video;let y;const b=g?u.audio:u.video;typeof b!="boolean"&&(y=b);const T=m.getSettings().deviceId;y!=null&&y.deviceId&&Ii(y.deviceId)!==T?y.deviceId=T:y||(y={deviceId:T});const C=Xy(m,y);return C.kind===j.Kind.Video?C.source=j.Source.Camera:C.kind===j.Kind.Audio&&(C.source=j.Source.Microphone),C.mediaStream=h,ti(C)&&r?yield C.setProcessor(r):Er(C)&&o&&(yield C.setProcessor(o)),C})))})}function Z1(a){return R(this,void 0,void 0,function*(){return(yield ab({audio:!1,video:a}))[0]})}function J1(a){return R(this,void 0,void 0,function*(){return(yield ab({audio:a,video:!1}))[0]})}class W1 extends Hi{get description(){return"Can publish audio"}perform(){return R(this,void 0,void 0,function*(){var e;const n=yield this.connect(),r=yield J1();if(yield Gy(r,1e3))throw new Error("unable to detect audio from microphone");this.appendMessage("detected audio from microphone"),n.localParticipant.publishTrack(r),yield new Promise(d=>setTimeout(d,3e3));const l=yield(e=r.sender)===null||e===void 0?void 0:e.getStats();if(!l)throw new Error("Could not get RTCStats");let u=0;if(l.forEach(d=>{d.type==="outbound-rtp"&&(d.kind==="audio"||!d.kind&&d.mediaType==="audio")&&(u=d.packetsSent)}),u===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(u," audio packets"))})}}class $1 extends Hi{get description(){return"Can publish video"}perform(){return R(this,void 0,void 0,function*(){var e;const n=yield this.connect(),r=yield Z1();yield this.checkForVideo(r.mediaStreamTrack),n.localParticipant.publishTrack(r),yield new Promise(u=>setTimeout(u,5e3));const o=yield(e=r.sender)===null||e===void 0?void 0:e.getStats();if(!o)throw new Error("Could not get RTCStats");let l=0;if(o.forEach(u=>{u.type==="outbound-rtp"&&(u.kind==="video"||!u.kind&&u.mediaType==="video")&&(l+=u.packetsSent)}),l===0)throw new Error("Could not determine packets are sent");this.appendMessage("published ".concat(l," video packets"))})}checkForVideo(e){return R(this,void 0,void 0,function*(){const n=new MediaStream;n.addTrack(e.clone());const r=document.createElement("video");r.srcObject=n,r.muted=!0,yield new Promise(o=>{r.onplay=()=>{setTimeout(()=>{var l,u,d,h;const m=document.createElement("canvas"),g=e.getSettings(),y=(u=(l=g.width)!==null&&l!==void 0?l:r.videoWidth)!==null&&u!==void 0?u:1280,b=(h=(d=g.height)!==null&&d!==void 0?d:r.videoHeight)!==null&&h!==void 0?h:720;m.width=y,m.height=b;const T=m.getContext("2d");T.drawImage(r,0,0);const k=T.getImageData(0,0,m.width,m.height).data;let w=!0;for(let O=0;O<k.length;O+=4)if(k[O]!==0||k[O+1]!==0||k[O+2]!==0){w=!1;break}w?this.appendError("camera appears to be producing only black frames"):this.appendMessage("received video frames"),o()},1e3)},r.play()}),r.remove()})}}class eR extends Hi{get description(){return"Resuming connection after interruption"}perform(){return R(this,void 0,void 0,function*(){var e;const n=yield this.connect();let r=!1,o=!1,l;const u=new Promise(m=>{setTimeout(m,5e3),l=m}),d=()=>{r=!0};n.on(B.SignalReconnecting,d).on(B.Reconnecting,d).on(B.Reconnected,()=>{o=!0,l(!0)}),(e=n.engine.client.ws)===null||e===void 0||e.close();const h=n.engine.client.onClose;if(h&&h(""),yield u,r){if(!o||n.state!==Te.Connected)throw this.appendWarning("reconnection is only possible in Redis-based configurations"),new Error("Not able to reconnect")}else throw new Error("Did not attempt to reconnect")})}}class tR extends Hi{get description(){return"Can connect via TURN"}perform(){return R(this,void 0,void 0,function*(){var e,n;const r=new Yf,o=yield r.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});let l=!1,u=!1,d=!1;for(let h of o.iceServers)for(let m of h.urls)m.startsWith("turn:")?(u=!0,d=!0):m.startsWith("turns:")&&(u=!0,d=!0,l=!0),m.startsWith("stun:")&&(d=!0);d?u&&!l&&this.appendWarning("TURN is configured server side, but TURN/TLS is unavailable."):this.appendWarning("No STUN servers configured on server side."),yield r.close(),!((n=(e=this.connectOptions)===null||e===void 0?void 0:e.rtcConfig)===null||n===void 0)&&n.iceServers||u?yield this.room.connect(this.url,this.token,{rtcConfig:{iceTransportPolicy:"relay"}}):(this.appendWarning("No TURN servers configured."),this.skip(),yield new Promise(h=>setTimeout(h,0)))})}}class nR extends Hi{get description(){return"Establishing WebRTC connection"}perform(){return R(this,void 0,void 0,function*(){let e=!1,n=!1;this.room.on(B.SignalConnected,()=>{const r=this.room.engine.client.onTrickle;this.room.engine.client.onTrickle=(o,l)=>{if(o.candidate){const u=new RTCIceCandidate(o);let d="".concat(u.protocol," ").concat(u.address,":").concat(u.port," ").concat(u.type);u.address&&(iR(u.address)?d+=" (private)":u.protocol==="tcp"&&u.tcpType==="passive"?(e=!0,d+=" (passive)"):u.protocol==="udp"&&(n=!0)),this.appendMessage(d)}r&&r(o,l)},this.room.engine.pcManager&&(this.room.engine.pcManager.subscriber.onIceCandidateError=o=>{o instanceof RTCPeerConnectionIceErrorEvent&&this.appendWarning("error with ICE candidate: ".concat(o.errorCode," ").concat(o.errorText," ").concat(o.url))})});try{yield this.connect(),ke.info("now the room is connected")}catch(r){throw this.appendWarning("ports need to be open on firewall in order to connect."),r}e||this.appendWarning("Server is not configured for ICE/TCP"),n||this.appendWarning("No public IPv4 UDP candidates were found. Your server is likely not configured correctly")})}}function iR(a){const e=a.split(".");if(e.length===4){if(e[0]==="10")return!0;if(e[0]==="192"&&e[1]==="168")return!0;if(e[0]==="172"){const n=parseInt(e[1],10);if(n>=16&&n<=31)return!0}}return!1}class aR extends Hi{get description(){return"Connecting to signal connection via WebSocket"}perform(){return R(this,void 0,void 0,function*(){var e,n,r;(this.url.startsWith("ws:")||this.url.startsWith("http:"))&&this.appendWarning("Server is insecure, clients may block connections to it");let o=new Yf;const l=yield o.join(this.url,this.token,{autoSubscribe:!0,maxRetries:0,e2eeEnabled:!1,websocketTimeout:15e3});this.appendMessage("Connected to server, version ".concat(l.serverVersion,".")),((e=l.serverInfo)===null||e===void 0?void 0:e.edition)===F0.Cloud&&(!((n=l.serverInfo)===null||n===void 0)&&n.region)&&this.appendMessage("LiveKit Cloud: ".concat((r=l.serverInfo)===null||r===void 0?void 0:r.region)),yield o.close()})}}class bO extends xn.EventEmitter{constructor(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};super(),this.options={},this.checkResults=new Map,this.url=e,this.token=n,this.options=r}getNextCheckId(){const e=this.checkResults.size;return this.checkResults.set(e,{logs:[],status:fn.IDLE,name:"",description:""}),e}updateCheck(e,n){this.checkResults.set(e,n),this.emit("checkUpdate",e,n)}isSuccess(){return Array.from(this.checkResults.values()).every(e=>e.status!==fn.FAILED)}getResults(){return Array.from(this.checkResults.values())}createAndRunCheck(e){return R(this,void 0,void 0,function*(){const n=this.getNextCheckId(),r=new e(this.url,this.token,this.options),o=u=>{this.updateCheck(n,u)};r.on("update",o);const l=yield r.run();return r.off("update",o),l})}checkWebsocket(){return R(this,void 0,void 0,function*(){return this.createAndRunCheck(aR)})}checkWebRTC(){return R(this,void 0,void 0,function*(){return this.createAndRunCheck(nR)})}checkTURN(){return R(this,void 0,void 0,function*(){return this.createAndRunCheck(tR)})}checkReconnect(){return R(this,void 0,void 0,function*(){return this.createAndRunCheck(eR)})}checkPublishAudio(){return R(this,void 0,void 0,function*(){return this.createAndRunCheck(W1)})}checkPublishVideo(){return R(this,void 0,void 0,function*(){return this.createAndRunCheck($1)})}checkConnectionProtocol(){return R(this,void 0,void 0,function*(){const e=yield this.createAndRunCheck(X1);if(e.data&&"protocol"in e.data){const n=e.data;this.options.protocol=n.protocol}return e})}checkCloudRegion(){return R(this,void 0,void 0,function*(){return this.createAndRunCheck(Q1)})}}const kf=Math.min,pr=Math.max,jc=Math.round,zi=a=>({x:a,y:a}),rR={left:"right",right:"left",bottom:"top",top:"bottom"},sR={start:"end",end:"start"};function e0(a,e,n){return pr(a,kf(e,n))}function Zc(a,e){return typeof a=="function"?a(e):a}function ya(a){return a.split("-")[0]}function Jc(a){return a.split("-")[1]}function rb(a){return a==="x"?"y":"x"}function sb(a){return a==="y"?"height":"width"}function Wc(a){return["top","bottom"].includes(ya(a))?"y":"x"}function ob(a){return rb(Wc(a))}function oR(a,e,n){n===void 0&&(n=!1);const r=Jc(a),o=ob(a),l=sb(o);let u=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[l]>e.floating[l]&&(u=Bc(u)),[u,Bc(u)]}function cR(a){const e=Bc(a);return[Cf(a),e,Cf(e)]}function Cf(a){return a.replace(/start|end/g,e=>sR[e])}function lR(a,e,n){const r=["left","right"],o=["right","left"],l=["top","bottom"],u=["bottom","top"];switch(a){case"top":case"bottom":return n?e?o:r:e?r:o;case"left":case"right":return e?l:u;default:return[]}}function uR(a,e,n,r){const o=Jc(a);let l=lR(ya(a),n==="start",r);return o&&(l=l.map(u=>u+"-"+o),e&&(l=l.concat(l.map(Cf)))),l}function Bc(a){return a.replace(/left|right|bottom|top/g,e=>rR[e])}function dR(a){return{top:0,right:0,bottom:0,left:0,...a}}function fR(a){return typeof a!="number"?dR(a):{top:a,right:a,bottom:a,left:a}}function zc(a){const{x:e,y:n,width:r,height:o}=a;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function t0(a,e,n){let{reference:r,floating:o}=a;const l=Wc(e),u=ob(e),d=sb(u),h=ya(e),m=l==="y",g=r.x+r.width/2-o.width/2,y=r.y+r.height/2-o.height/2,b=r[d]/2-o[d]/2;let T;switch(h){case"top":T={x:g,y:r.y-o.height};break;case"bottom":T={x:g,y:r.y+r.height};break;case"right":T={x:r.x+r.width,y};break;case"left":T={x:r.x-o.width,y};break;default:T={x:r.x,y:r.y}}switch(Jc(e)){case"start":T[u]-=b*(n&&m?-1:1);break;case"end":T[u]+=b*(n&&m?-1:1);break}return T}const hR=async(a,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:l=[],platform:u}=n,d=l.filter(Boolean),h=await(u.isRTL==null?void 0:u.isRTL(e));let m=await u.getElementRects({reference:a,floating:e,strategy:o}),{x:g,y}=t0(m,r,h),b=r,T={},C=0;for(let k=0;k<d.length;k++){const{name:w,fn:O}=d[k],{x:V,y:Q,data:U,reset:_}=await O({x:g,y,initialPlacement:r,placement:b,strategy:o,middlewareData:T,rects:m,platform:u,elements:{reference:a,floating:e}});g=V??g,y=Q??y,T={...T,[w]:{...T[w],...U}},_&&C<=50&&(C++,typeof _=="object"&&(_.placement&&(b=_.placement),_.rects&&(m=_.rects===!0?await u.getElementRects({reference:a,floating:e,strategy:o}):_.rects),{x:g,y}=t0(m,b,h)),k=-1)}return{x:g,y,placement:b,strategy:o,middlewareData:T}};async function cb(a,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:l,rects:u,elements:d,strategy:h}=a,{boundary:m="clippingAncestors",rootBoundary:g="viewport",elementContext:y="floating",altBoundary:b=!1,padding:T=0}=Zc(e,a),C=fR(T),k=d[b?y==="floating"?"reference":"floating":y],w=zc(await l.getClippingRect({element:(n=await(l.isElement==null?void 0:l.isElement(k)))==null||n?k:k.contextElement||await(l.getDocumentElement==null?void 0:l.getDocumentElement(d.floating)),boundary:m,rootBoundary:g,strategy:h})),O=y==="floating"?{...u.floating,x:r,y:o}:u.reference,V=await(l.getOffsetParent==null?void 0:l.getOffsetParent(d.floating)),Q=await(l.isElement==null?void 0:l.isElement(V))?await(l.getScale==null?void 0:l.getScale(V))||{x:1,y:1}:{x:1,y:1},U=zc(l.convertOffsetParentRelativeRectToViewportRelativeRect?await l.convertOffsetParentRelativeRectToViewportRelativeRect({elements:d,rect:O,offsetParent:V,strategy:h}):O);return{top:(w.top-U.top+C.top)/Q.y,bottom:(U.bottom-w.bottom+C.bottom)/Q.y,left:(w.left-U.left+C.left)/Q.x,right:(U.right-w.right+C.right)/Q.x}}const mR=function(a){return a===void 0&&(a={}),{name:"flip",options:a,async fn(e){var n,r;const{placement:o,middlewareData:l,rects:u,initialPlacement:d,platform:h,elements:m}=e,{mainAxis:g=!0,crossAxis:y=!0,fallbackPlacements:b,fallbackStrategy:T="bestFit",fallbackAxisSideDirection:C="none",flipAlignment:k=!0,...w}=Zc(a,e);if((n=l.arrow)!=null&&n.alignmentOffset)return{};const O=ya(o),V=ya(d)===d,Q=await(h.isRTL==null?void 0:h.isRTL(m.floating)),U=b||(V||!k?[Bc(d)]:cR(d));!b&&C!=="none"&&U.push(...uR(d,k,C,Q));const _=[d,...U],H=await cb(e,w),$=[];let ie=((r=l.flip)==null?void 0:r.overflows)||[];if(g&&$.push(H[O]),y){const oe=oR(o,u,Q);$.push(H[oe[0]],H[oe[1]])}if(ie=[...ie,{placement:o,overflows:$}],!$.every(oe=>oe<=0)){var X,J;const oe=(((X=l.flip)==null?void 0:X.index)||0)+1,qe=_[oe];if(qe)return{data:{index:oe,overflows:ie},reset:{placement:qe}};let Fe=(J=ie.filter(Ye=>Ye.overflows[0]<=0).sort((Ye,te)=>Ye.overflows[1]-te.overflows[1])[0])==null?void 0:J.placement;if(!Fe)switch(T){case"bestFit":{var ee;const Ye=(ee=ie.map(te=>[te.placement,te.overflows.filter(he=>he>0).reduce((he,ue)=>he+ue,0)]).sort((te,he)=>te[1]-he[1])[0])==null?void 0:ee[0];Ye&&(Fe=Ye);break}case"initialPlacement":Fe=d;break}if(o!==Fe)return{reset:{placement:Fe}}}return{}}}};async function pR(a,e){const{placement:n,platform:r,elements:o}=a,l=await(r.isRTL==null?void 0:r.isRTL(o.floating)),u=ya(n),d=Jc(n),h=Wc(n)==="y",m=["left","top"].includes(u)?-1:1,g=l&&h?-1:1,y=Zc(e,a);let{mainAxis:b,crossAxis:T,alignmentAxis:C}=typeof y=="number"?{mainAxis:y,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...y};return d&&typeof C=="number"&&(T=d==="end"?C*-1:C),h?{x:T*g,y:b*m}:{x:b*m,y:T*g}}const gR=function(a){return a===void 0&&(a=0),{name:"offset",options:a,async fn(e){var n,r;const{x:o,y:l,placement:u,middlewareData:d}=e,h=await pR(e,a);return u===((n=d.offset)==null?void 0:n.placement)&&(r=d.arrow)!=null&&r.alignmentOffset?{}:{x:o+h.x,y:l+h.y,data:{...h,placement:u}}}}},vR=function(a){return a===void 0&&(a={}),{name:"shift",options:a,async fn(e){const{x:n,y:r,placement:o}=e,{mainAxis:l=!0,crossAxis:u=!1,limiter:d={fn:w=>{let{x:O,y:V}=w;return{x:O,y:V}}},...h}=Zc(a,e),m={x:n,y:r},g=await cb(e,h),y=Wc(ya(o)),b=rb(y);let T=m[b],C=m[y];if(l){const w=b==="y"?"top":"left",O=b==="y"?"bottom":"right",V=T+g[w],Q=T-g[O];T=e0(V,T,Q)}if(u){const w=y==="y"?"top":"left",O=y==="y"?"bottom":"right",V=C+g[w],Q=C-g[O];C=e0(V,C,Q)}const k=d.fn({...e,[b]:T,[y]:C});return{...k,data:{x:k.x-n,y:k.y-r}}}}};function $c(){return typeof window<"u"}function Rr(a){return lb(a)?(a.nodeName||"").toLowerCase():"#document"}function Gt(a){var e;return(a==null||(e=a.ownerDocument)==null?void 0:e.defaultView)||window}function ii(a){var e;return(e=(lb(a)?a.ownerDocument:a.document)||window.document)==null?void 0:e.documentElement}function lb(a){return $c()?a instanceof Node||a instanceof Gt(a).Node:!1}function vn(a){return $c()?a instanceof Element||a instanceof Gt(a).Element:!1}function Mn(a){return $c()?a instanceof HTMLElement||a instanceof Gt(a).HTMLElement:!1}function n0(a){return!$c()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof Gt(a).ShadowRoot}function Ys(a){const{overflow:e,overflowX:n,overflowY:r,display:o}=yn(a);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(o)}function yR(a){return["table","td","th"].includes(Rr(a))}function el(a){return[":popover-open",":modal"].some(e=>{try{return a.matches(e)}catch{return!1}})}function Wf(a){const e=$f(),n=vn(a)?yn(a):a;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function bR(a){let e=qi(a);for(;Mn(e)&&!Tr(e);){if(Wf(e))return e;if(el(e))return null;e=qi(e)}return null}function $f(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Tr(a){return["html","body","#document"].includes(Rr(a))}function yn(a){return Gt(a).getComputedStyle(a)}function tl(a){return vn(a)?{scrollLeft:a.scrollLeft,scrollTop:a.scrollTop}:{scrollLeft:a.scrollX,scrollTop:a.scrollY}}function qi(a){if(Rr(a)==="html")return a;const e=a.assignedSlot||a.parentNode||n0(a)&&a.host||ii(a);return n0(e)?e.host:e}function ub(a){const e=qi(a);return Tr(e)?a.ownerDocument?a.ownerDocument.body:a.body:Mn(e)&&Ys(e)?e:ub(e)}function db(a,e,n){var r;e===void 0&&(e=[]);const o=ub(a),l=o===((r=a.ownerDocument)==null?void 0:r.body),u=Gt(o);return l?(Ef(u),e.concat(u,u.visualViewport||[],Ys(o)?o:[],[])):e.concat(o,db(o,[]))}function Ef(a){return a.parent&&Object.getPrototypeOf(a.parent)?a.frameElement:null}function fb(a){const e=yn(a);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Mn(a),l=o?a.offsetWidth:n,u=o?a.offsetHeight:r,d=jc(n)!==l||jc(r)!==u;return d&&(n=l,r=u),{width:n,height:r,$:d}}function hb(a){return vn(a)?a:a.contextElement}function gr(a){const e=hb(a);if(!Mn(e))return zi(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:l}=fb(e);let u=(l?jc(n.width):n.width)/r,d=(l?jc(n.height):n.height)/o;return(!u||!Number.isFinite(u))&&(u=1),(!d||!Number.isFinite(d))&&(d=1),{x:u,y:d}}const SR=zi(0);function mb(a){const e=Gt(a);return!$f()||!e.visualViewport?SR:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function TR(a,e,n){return e===void 0&&(e=!1),!n||e&&n!==Gt(a)?!1:e}function Gs(a,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=a.getBoundingClientRect(),l=hb(a);let u=zi(1);e&&(r?vn(r)&&(u=gr(r)):u=gr(a));const d=TR(l,n,r)?mb(l):zi(0);let h=(o.left+d.x)/u.x,m=(o.top+d.y)/u.y,g=o.width/u.x,y=o.height/u.y;if(l){const b=Gt(l),T=r&&vn(r)?Gt(r):r;let C=b,k=Ef(C);for(;k&&r&&T!==C;){const w=gr(k),O=k.getBoundingClientRect(),V=yn(k),Q=O.left+(k.clientLeft+parseFloat(V.paddingLeft))*w.x,U=O.top+(k.clientTop+parseFloat(V.paddingTop))*w.y;h*=w.x,m*=w.y,g*=w.x,y*=w.y,h+=Q,m+=U,C=Gt(k),k=Ef(C)}}return zc({width:g,height:y,x:h,y:m})}function kR(a){let{elements:e,rect:n,offsetParent:r,strategy:o}=a;const l=o==="fixed",u=ii(r),d=e?el(e.floating):!1;if(r===u||d&&l)return n;let h={scrollLeft:0,scrollTop:0},m=zi(1);const g=zi(0),y=Mn(r);if((y||!y&&!l)&&((Rr(r)!=="body"||Ys(u))&&(h=tl(r)),Mn(r))){const b=Gs(r);m=gr(r),g.x=b.x+r.clientLeft,g.y=b.y+r.clientTop}return{width:n.width*m.x,height:n.height*m.y,x:n.x*m.x-h.scrollLeft*m.x+g.x,y:n.y*m.y-h.scrollTop*m.y+g.y}}function CR(a){return Array.from(a.getClientRects())}function Rf(a,e){const n=tl(a).scrollLeft;return e?e.left+n:Gs(ii(a)).left+n}function ER(a){const e=ii(a),n=tl(a),r=a.ownerDocument.body,o=pr(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),l=pr(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let u=-n.scrollLeft+Rf(a);const d=-n.scrollTop;return yn(r).direction==="rtl"&&(u+=pr(e.clientWidth,r.clientWidth)-o),{width:o,height:l,x:u,y:d}}function RR(a,e){const n=Gt(a),r=ii(a),o=n.visualViewport;let l=r.clientWidth,u=r.clientHeight,d=0,h=0;if(o){l=o.width,u=o.height;const m=$f();(!m||m&&e==="fixed")&&(d=o.offsetLeft,h=o.offsetTop)}return{width:l,height:u,x:d,y:h}}function _R(a,e){const n=Gs(a,!0,e==="fixed"),r=n.top+a.clientTop,o=n.left+a.clientLeft,l=Mn(a)?gr(a):zi(1),u=a.clientWidth*l.x,d=a.clientHeight*l.y,h=o*l.x,m=r*l.y;return{width:u,height:d,x:h,y:m}}function i0(a,e,n){let r;if(e==="viewport")r=RR(a,n);else if(e==="document")r=ER(ii(a));else if(vn(e))r=_R(e,n);else{const o=mb(a);r={...e,x:e.x-o.x,y:e.y-o.y}}return zc(r)}function pb(a,e){const n=qi(a);return n===e||!vn(n)||Tr(n)?!1:yn(n).position==="fixed"||pb(n,e)}function wR(a,e){const n=e.get(a);if(n)return n;let r=db(a,[]).filter(d=>vn(d)&&Rr(d)!=="body"),o=null;const l=yn(a).position==="fixed";let u=l?qi(a):a;for(;vn(u)&&!Tr(u);){const d=yn(u),h=Wf(u);!h&&d.position==="fixed"&&(o=null),(l?!h&&!o:!h&&d.position==="static"&&o&&["absolute","fixed"].includes(o.position)||Ys(u)&&!h&&pb(a,u))?r=r.filter(m=>m!==u):o=d,u=qi(u)}return e.set(a,r),r}function OR(a){let{element:e,boundary:n,rootBoundary:r,strategy:o}=a;const l=[...n==="clippingAncestors"?el(e)?[]:wR(e,this._c):[].concat(n),r],u=l[0],d=l.reduce((h,m)=>{const g=i0(e,m,o);return h.top=pr(g.top,h.top),h.right=kf(g.right,h.right),h.bottom=kf(g.bottom,h.bottom),h.left=pr(g.left,h.left),h},i0(e,u,o));return{width:d.right-d.left,height:d.bottom-d.top,x:d.left,y:d.top}}function DR(a){const{width:e,height:n}=fb(a);return{width:e,height:n}}function AR(a,e,n){const r=Mn(e),o=ii(e),l=n==="fixed",u=Gs(a,!0,l,e);let d={scrollLeft:0,scrollTop:0};const h=zi(0);if(r||!r&&!l)if((Rr(e)!=="body"||Ys(o))&&(d=tl(e)),r){const T=Gs(e,!0,l,e);h.x=T.x+e.clientLeft,h.y=T.y+e.clientTop}else o&&(h.x=Rf(o));let m=0,g=0;if(o&&!r&&!l){const T=o.getBoundingClientRect();g=T.top+d.scrollTop,m=T.left+d.scrollLeft-Rf(o,T)}const y=u.left+d.scrollLeft-h.x-m,b=u.top+d.scrollTop-h.y-g;return{x:y,y:b,width:u.width,height:u.height}}function Bd(a){return yn(a).position==="static"}function a0(a,e){if(!Mn(a)||yn(a).position==="fixed")return null;if(e)return e(a);let n=a.offsetParent;return ii(a)===n&&(n=n.ownerDocument.body),n}function gb(a,e){const n=Gt(a);if(el(a))return n;if(!Mn(a)){let o=qi(a);for(;o&&!Tr(o);){if(vn(o)&&!Bd(o))return o;o=qi(o)}return n}let r=a0(a,e);for(;r&&yR(r)&&Bd(r);)r=a0(r,e);return r&&Tr(r)&&Bd(r)&&!Wf(r)?n:r||bR(a)||n}const MR=async function(a){const e=this.getOffsetParent||gb,n=this.getDimensions,r=await n(a.floating);return{reference:AR(a.reference,await e(a.floating),a.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function PR(a){return yn(a).direction==="rtl"}const xR={convertOffsetParentRelativeRectToViewportRelativeRect:kR,getDocumentElement:ii,getClippingRect:OR,getOffsetParent:gb,getElementRects:MR,getClientRects:CR,getDimensions:DR,getScale:gr,isElement:vn,isRTL:PR},NR=gR,UR=vR,LR=mR,IR=(a,e,n)=>{const r=new Map,o={platform:xR,...n},l={...o.platform,_c:r};return hR(a,e,{...o,platform:l})};var Ns=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jR(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var vb={exports:{}};(function(a){(function(e,n){a.exports?a.exports=n():e.log=n()})(Ns,function(){var e=function(){},n="undefined",r=typeof window!==n&&typeof window.navigator!==n&&/Trident\/|MSIE /.test(window.navigator.userAgent),o=["trace","debug","info","warn","error"],l={},u=null;function d(k,w){var O=k[w];if(typeof O.bind=="function")return O.bind(k);try{return Function.prototype.bind.call(O,k)}catch{return function(){return Function.prototype.apply.apply(O,[k,arguments])}}}function h(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function m(k){return k==="debug"&&(k="log"),typeof console===n?!1:k==="trace"&&r?h:console[k]!==void 0?d(console,k):console.log!==void 0?d(console,"log"):e}function g(){for(var k=this.getLevel(),w=0;w<o.length;w++){var O=o[w];this[O]=w<k?e:this.methodFactory(O,k,this.name)}if(this.log=this.debug,typeof console===n&&k<this.levels.SILENT)return"No console available for logging"}function y(k){return function(){typeof console!==n&&(g.call(this),this[k].apply(this,arguments))}}function b(k,w,O){return m(k)||y.apply(this,arguments)}function T(k,w){var O=this,V,Q,U,_="loglevel";typeof k=="string"?_+=":"+k:typeof k=="symbol"&&(_=void 0);function H(ee){var oe=(o[ee]||"silent").toUpperCase();if(!(typeof window===n||!_)){try{window.localStorage[_]=oe;return}catch{}try{window.document.cookie=encodeURIComponent(_)+"="+oe+";"}catch{}}}function $(){var ee;if(!(typeof window===n||!_)){try{ee=window.localStorage[_]}catch{}if(typeof ee===n)try{var oe=window.document.cookie,qe=encodeURIComponent(_),Fe=oe.indexOf(qe+"=");Fe!==-1&&(ee=/^([^;]+)/.exec(oe.slice(Fe+qe.length+1))[1])}catch{}return O.levels[ee]===void 0&&(ee=void 0),ee}}function ie(){if(!(typeof window===n||!_)){try{window.localStorage.removeItem(_)}catch{}try{window.document.cookie=encodeURIComponent(_)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function X(ee){var oe=ee;if(typeof oe=="string"&&O.levels[oe.toUpperCase()]!==void 0&&(oe=O.levels[oe.toUpperCase()]),typeof oe=="number"&&oe>=0&&oe<=O.levels.SILENT)return oe;throw new TypeError("log.setLevel() called with invalid level: "+ee)}O.name=k,O.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},O.methodFactory=w||b,O.getLevel=function(){return U??Q??V},O.setLevel=function(ee,oe){return U=X(ee),oe!==!1&&H(U),g.call(O)},O.setDefaultLevel=function(ee){Q=X(ee),$()||O.setLevel(ee,!1)},O.resetLevel=function(){U=null,ie(),g.call(O)},O.enableAll=function(ee){O.setLevel(O.levels.TRACE,ee)},O.disableAll=function(ee){O.setLevel(O.levels.SILENT,ee)},O.rebuild=function(){if(u!==O&&(V=X(u.getLevel())),g.call(O),u===O)for(var ee in l)l[ee].rebuild()},V=X(u?u.getLevel():"WARN");var J=$();J!=null&&(U=X(J)),g.call(O)}u=new T,u.getLogger=function(k){if(typeof k!="symbol"&&typeof k!="string"||k==="")throw new TypeError("You must supply a name when creating a logger.");var w=l[k];return w||(w=l[k]=new T(k,u.methodFactory)),w};var C=typeof window!==n?window.log:void 0;return u.noConflict=function(){return typeof window!==n&&window.log===u&&(window.log=C),u},u.getLoggers=function(){return l},u.default=u,u})})(vb);var BR=vb.exports;const zR=jR(BR);var _f=function(a,e){return _f=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(n[o]=r[o])},_f(a,e)};function ai(a,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");_f(a,e);function n(){this.constructor=a}a.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}function qR(a,e,n,r){function o(l){return l instanceof n?l:new n(function(u){u(l)})}return new(n||(n=Promise))(function(l,u){function d(g){try{m(r.next(g))}catch(y){u(y)}}function h(g){try{m(r.throw(g))}catch(y){u(y)}}function m(g){g.done?l(g.value):o(g.value).then(d,h)}m((r=r.apply(a,[])).next())})}function yb(a,e){var n={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},r,o,l,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=d(0),u.throw=d(1),u.return=d(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function d(m){return function(g){return h([m,g])}}function h(m){if(r)throw new TypeError("Generator is already executing.");for(;u&&(u=0,m[0]&&(n=0)),n;)try{if(r=1,o&&(l=m[0]&2?o.return:m[0]?o.throw||((l=o.return)&&l.call(o),0):o.next)&&!(l=l.call(o,m[1])).done)return l;switch(o=0,l&&(m=[m[0]&2,l.value]),m[0]){case 0:case 1:l=m;break;case 4:return n.label++,{value:m[1],done:!1};case 5:n.label++,o=m[1],m=[0];continue;case 7:m=n.ops.pop(),n.trys.pop();continue;default:if(l=n.trys,!(l=l.length>0&&l[l.length-1])&&(m[0]===6||m[0]===2)){n=0;continue}if(m[0]===3&&(!l||m[1]>l[0]&&m[1]<l[3])){n.label=m[1];break}if(m[0]===6&&n.label<l[1]){n.label=l[1],l=m;break}if(l&&n.label<l[2]){n.label=l[2],n.ops.push(m);break}l[2]&&n.ops.pop(),n.trys.pop();continue}m=e.call(a,n)}catch(g){m=[6,g],o=0}finally{r=l=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}}function kr(a){var e=typeof Symbol=="function"&&Symbol.iterator,n=e&&a[e],r=0;if(n)return n.call(a);if(a&&typeof a.length=="number")return{next:function(){return a&&r>=a.length&&(a=void 0),{value:a&&a[r++],done:!a}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function qc(a,e){var n=typeof Symbol=="function"&&a[Symbol.iterator];if(!n)return a;var r=n.call(a),o,l=[],u;try{for(;(e===void 0||e-- >0)&&!(o=r.next()).done;)l.push(o.value)}catch(d){u={error:d}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(u)throw u.error}}return l}function Vc(a,e,n){if(arguments.length===2)for(var r=0,o=e.length,l;r<o;r++)(l||!(r in e))&&(l||(l=Array.prototype.slice.call(e,0,r)),l[r]=e[r]);return a.concat(l||Array.prototype.slice.call(e))}function vr(a){return this instanceof vr?(this.v=a,this):new vr(a)}function VR(a,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=n.apply(a,e||[]),o,l=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),d("next"),d("throw"),d("return",u),o[Symbol.asyncIterator]=function(){return this},o;function u(T){return function(C){return Promise.resolve(C).then(T,y)}}function d(T,C){r[T]&&(o[T]=function(k){return new Promise(function(w,O){l.push([T,k,w,O])>1||h(T,k)})},C&&(o[T]=C(o[T])))}function h(T,C){try{m(r[T](C))}catch(k){b(l[0][3],k)}}function m(T){T.value instanceof vr?Promise.resolve(T.value.v).then(g,y):b(l[0][2],T)}function g(T){h("next",T)}function y(T){h("throw",T)}function b(T,C){T(C),l.shift(),l.length&&h(l[0][0],l[0][1])}}function HR(a){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=a[Symbol.asyncIterator],n;return e?e.call(a):(a=typeof kr=="function"?kr(a):a[Symbol.iterator](),n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n);function r(l){n[l]=a[l]&&function(u){return new Promise(function(d,h){u=a[l](u),o(d,h,u.done,u.value)})}}function o(l,u,d,h){Promise.resolve(h).then(function(m){l({value:m,done:d})},u)}}function dt(a){return typeof a=="function"}function eh(a){var e=function(r){Error.call(r),r.stack=new Error().stack},n=a(e);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var zd=eh(function(a){return function(e){a(this),this.message=e?e.length+` errors occurred during unsubscription:
`+e.map(function(n,r){return r+1+") "+n.toString()}).join(`
  `):"",this.name="UnsubscriptionError",this.errors=e}});function Hc(a,e){if(a){var n=a.indexOf(e);0<=n&&a.splice(n,1)}}var Ks=function(){function a(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return a.prototype.unsubscribe=function(){var e,n,r,o,l;if(!this.closed){this.closed=!0;var u=this._parentage;if(u)if(this._parentage=null,Array.isArray(u))try{for(var d=kr(u),h=d.next();!h.done;h=d.next()){var m=h.value;m.remove(this)}}catch(k){e={error:k}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(e)throw e.error}}else u.remove(this);var g=this.initialTeardown;if(dt(g))try{g()}catch(k){l=k instanceof zd?k.errors:[k]}var y=this._finalizers;if(y){this._finalizers=null;try{for(var b=kr(y),T=b.next();!T.done;T=b.next()){var C=T.value;try{r0(C)}catch(k){l=l??[],k instanceof zd?l=Vc(Vc([],qc(l)),qc(k.errors)):l.push(k)}}}catch(k){r={error:k}}finally{try{T&&!T.done&&(o=b.return)&&o.call(b)}finally{if(r)throw r.error}}}if(l)throw new zd(l)}},a.prototype.add=function(e){var n;if(e&&e!==this)if(this.closed)r0(e);else{if(e instanceof a){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(e)}},a.prototype._hasParent=function(e){var n=this._parentage;return n===e||Array.isArray(n)&&n.includes(e)},a.prototype._addParent=function(e){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(e),n):n?[n,e]:e},a.prototype._removeParent=function(e){var n=this._parentage;n===e?this._parentage=null:Array.isArray(n)&&Hc(n,e)},a.prototype.remove=function(e){var n=this._finalizers;n&&Hc(n,e),e instanceof a&&e._removeParent(this)},a.EMPTY=function(){var e=new a;return e.closed=!0,e}(),a}(),bb=Ks.EMPTY;function Sb(a){return a instanceof Ks||a&&"closed"in a&&dt(a.remove)&&dt(a.add)&&dt(a.unsubscribe)}function r0(a){dt(a)?a():a.unsubscribe()}var GR={Promise:void 0},FR={setTimeout:function(a,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setTimeout.apply(void 0,Vc([a,e],qc(n)))},clearTimeout:function(a){return clearTimeout(a)},delegate:void 0};function Tb(a){FR.setTimeout(function(){throw a})}function s0(){}function Ac(a){a()}var th=function(a){ai(e,a);function e(n){var r=a.call(this)||this;return r.isStopped=!1,n?(r.destination=n,Sb(n)&&n.add(r)):r.destination=QR,r}return e.create=function(n,r,o){return new wf(n,r,o)},e.prototype.next=function(n){this.isStopped||this._next(n)},e.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,a.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(n){this.destination.next(n)},e.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Ks),YR=function(){function a(e){this.partialObserver=e}return a.prototype.next=function(e){var n=this.partialObserver;if(n.next)try{n.next(e)}catch(r){mc(r)}},a.prototype.error=function(e){var n=this.partialObserver;if(n.error)try{n.error(e)}catch(r){mc(r)}else mc(e)},a.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(n){mc(n)}},a}(),wf=function(a){ai(e,a);function e(n,r,o){var l=a.call(this)||this,u;return dt(n)||!n?u={next:n??void 0,error:r??void 0,complete:o??void 0}:u=n,l.destination=new YR(u),l}return e}(th);function mc(a){Tb(a)}function KR(a){throw a}var QR={closed:!0,next:s0,error:KR,complete:s0},nh=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function kb(a){return a}function XR(a){return a.length===0?kb:a.length===1?a[0]:function(e){return a.reduce(function(n,r){return r(n)},e)}}var vt=function(){function a(e){e&&(this._subscribe=e)}return a.prototype.lift=function(e){var n=new a;return n.source=this,n.operator=e,n},a.prototype.subscribe=function(e,n,r){var o=this,l=JR(e)?e:new wf(e,n,r);return Ac(function(){var u=o,d=u.operator,h=u.source;l.add(d?d.call(l,h):h?o._subscribe(l):o._trySubscribe(l))}),l},a.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(n){e.error(n)}},a.prototype.forEach=function(e,n){var r=this;return n=o0(n),new n(function(o,l){var u=new wf({next:function(d){try{e(d)}catch(h){l(h),u.unsubscribe()}},error:l,complete:o});r.subscribe(u)})},a.prototype._subscribe=function(e){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(e)},a.prototype[nh]=function(){return this},a.prototype.pipe=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return XR(e)(this)},a.prototype.toPromise=function(e){var n=this;return e=o0(e),new e(function(r,o){var l;n.subscribe(function(u){return l=u},function(u){return o(u)},function(){return r(l)})})},a.create=function(e){return new a(e)},a}();function o0(a){var e;return(e=a??GR.Promise)!==null&&e!==void 0?e:Promise}function ZR(a){return a&&dt(a.next)&&dt(a.error)&&dt(a.complete)}function JR(a){return a&&a instanceof th||ZR(a)&&Sb(a)}function WR(a){return dt(a==null?void 0:a.lift)}function Sa(a){return function(e){if(WR(e))return e.lift(function(n){try{return a(n,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function Fs(a,e,n,r,o){return new $R(a,e,n,r,o)}var $R=function(a){ai(e,a);function e(n,r,o,l,u,d){var h=a.call(this,n)||this;return h.onFinalize=u,h.shouldUnsubscribe=d,h._next=r?function(m){try{r(m)}catch(g){n.error(g)}}:a.prototype._next,h._error=l?function(m){try{l(m)}catch(g){n.error(g)}finally{this.unsubscribe()}}:a.prototype._error,h._complete=o?function(){try{o()}catch(m){n.error(m)}finally{this.unsubscribe()}}:a.prototype._complete,h}return e.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;a.prototype.unsubscribe.call(this),!r&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},e}(th),e_=eh(function(a){return function(){a(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Cr=function(a){ai(e,a);function e(){var n=a.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return e.prototype.lift=function(n){var r=new c0(this,this);return r.operator=n,r},e.prototype._throwIfClosed=function(){if(this.closed)throw new e_},e.prototype.next=function(n){var r=this;Ac(function(){var o,l;if(r._throwIfClosed(),!r.isStopped){r.currentObservers||(r.currentObservers=Array.from(r.observers));try{for(var u=kr(r.currentObservers),d=u.next();!d.done;d=u.next()){var h=d.value;h.next(n)}}catch(m){o={error:m}}finally{try{d&&!d.done&&(l=u.return)&&l.call(u)}finally{if(o)throw o.error}}}})},e.prototype.error=function(n){var r=this;Ac(function(){if(r._throwIfClosed(),!r.isStopped){r.hasError=r.isStopped=!0,r.thrownError=n;for(var o=r.observers;o.length;)o.shift().error(n)}})},e.prototype.complete=function(){var n=this;Ac(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var r=n.observers;r.length;)r.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(n){return this._throwIfClosed(),a.prototype._trySubscribe.call(this,n)},e.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},e.prototype._innerSubscribe=function(n){var r=this,o=this,l=o.hasError,u=o.isStopped,d=o.observers;return l||u?bb:(this.currentObservers=null,d.push(n),new Ks(function(){r.currentObservers=null,Hc(d,n)}))},e.prototype._checkFinalizedStatuses=function(n){var r=this,o=r.hasError,l=r.thrownError,u=r.isStopped;o?n.error(l):u&&n.complete()},e.prototype.asObservable=function(){var n=new vt;return n.source=this,n},e.create=function(n,r){return new c0(n,r)},e}(vt),c0=function(a){ai(e,a);function e(n,r){var o=a.call(this)||this;return o.destination=n,o.source=r,o}return e.prototype.next=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.next)===null||o===void 0||o.call(r,n)},e.prototype.error=function(n){var r,o;(o=(r=this.destination)===null||r===void 0?void 0:r.error)===null||o===void 0||o.call(r,n)},e.prototype.complete=function(){var n,r;(r=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||r===void 0||r.call(n)},e.prototype._subscribe=function(n){var r,o;return(o=(r=this.source)===null||r===void 0?void 0:r.subscribe(n))!==null&&o!==void 0?o:bb},e}(Cr),t_=function(a){ai(e,a);function e(n){var r=a.call(this)||this;return r._value=n,r}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(n){var r=a.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},e.prototype.getValue=function(){var n=this,r=n.hasError,o=n.thrownError,l=n._value;if(r)throw o;return this._throwIfClosed(),l},e.prototype.next=function(n){a.prototype.next.call(this,this._value=n)},e}(Cr),n_={now:function(){return Date.now()}},i_=function(a){ai(e,a);function e(n,r){return a.call(this)||this}return e.prototype.schedule=function(n,r){return this},e}(Ks),l0={setInterval:function(a,e){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];return setInterval.apply(void 0,Vc([a,e],qc(n)))},clearInterval:function(a){return clearInterval(a)},delegate:void 0},a_=function(a){ai(e,a);function e(n,r){var o=a.call(this,n,r)||this;return o.scheduler=n,o.work=r,o.pending=!1,o}return e.prototype.schedule=function(n,r){var o;if(r===void 0&&(r=0),this.closed)return this;this.state=n;var l=this.id,u=this.scheduler;return l!=null&&(this.id=this.recycleAsyncId(u,l,r)),this.pending=!0,this.delay=r,this.id=(o=this.id)!==null&&o!==void 0?o:this.requestAsyncId(u,this.id,r),this},e.prototype.requestAsyncId=function(n,r,o){return o===void 0&&(o=0),l0.setInterval(n.flush.bind(n,this),o)},e.prototype.recycleAsyncId=function(n,r,o){if(o===void 0&&(o=0),o!=null&&this.delay===o&&this.pending===!1)return r;r!=null&&l0.clearInterval(r)},e.prototype.execute=function(n,r){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var o=this._execute(n,r);if(o)return o;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(n,r){var o=!1,l;try{this.work(n)}catch(u){o=!0,l=u||new Error("Scheduled action threw falsy error")}if(o)return this.unsubscribe(),l},e.prototype.unsubscribe=function(){if(!this.closed){var n=this,r=n.id,o=n.scheduler,l=o.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Hc(l,this),r!=null&&(this.id=this.recycleAsyncId(o,r,null)),this.delay=null,a.prototype.unsubscribe.call(this)}},e}(i_),u0=function(){function a(e,n){n===void 0&&(n=a.now),this.schedulerActionCtor=e,this.now=n}return a.prototype.schedule=function(e,n,r){return n===void 0&&(n=0),new this.schedulerActionCtor(this,e).schedule(r,n)},a.now=n_.now,a}(),r_=function(a){ai(e,a);function e(n,r){r===void 0&&(r=u0.now);var o=a.call(this,n,r)||this;return o.actions=[],o._active=!1,o}return e.prototype.flush=function(n){var r=this.actions;if(this._active){r.push(n);return}var o;this._active=!0;do if(o=n.execute(n.state,n.delay))break;while(n=r.shift());if(this._active=!1,o){for(;n=r.shift();)n.unsubscribe();throw o}},e}(u0);new r_(a_);function s_(a){return a&&dt(a.schedule)}function o_(a){return a[a.length-1]}function Cb(a){return s_(o_(a))?a.pop():void 0}var Eb=function(a){return a&&typeof a.length=="number"&&typeof a!="function"};function Rb(a){return dt(a==null?void 0:a.then)}function _b(a){return dt(a[nh])}function wb(a){return Symbol.asyncIterator&&dt(a==null?void 0:a[Symbol.asyncIterator])}function Ob(a){return new TypeError("You provided "+(a!==null&&typeof a=="object"?"an invalid object":"'"+a+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function c_(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Db=c_();function Ab(a){return dt(a==null?void 0:a[Db])}function Mb(a){return VR(this,arguments,function(){var e,n,r,o;return yb(this,function(l){switch(l.label){case 0:e=a.getReader(),l.label=1;case 1:l.trys.push([1,,9,10]),l.label=2;case 2:return[4,vr(e.read())];case 3:return n=l.sent(),r=n.value,o=n.done,o?[4,vr(void 0)]:[3,5];case 4:return[2,l.sent()];case 5:return[4,vr(r)];case 6:return[4,l.sent()];case 7:return l.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Pb(a){return dt(a==null?void 0:a.getReader)}function Qs(a){if(a instanceof vt)return a;if(a!=null){if(_b(a))return l_(a);if(Eb(a))return u_(a);if(Rb(a))return d_(a);if(wb(a))return xb(a);if(Ab(a))return f_(a);if(Pb(a))return h_(a)}throw Ob(a)}function l_(a){return new vt(function(e){var n=a[nh]();if(dt(n.subscribe))return n.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function u_(a){return new vt(function(e){for(var n=0;n<a.length&&!e.closed;n++)e.next(a[n]);e.complete()})}function d_(a){return new vt(function(e){a.then(function(n){e.closed||(e.next(n),e.complete())},function(n){return e.error(n)}).then(null,Tb)})}function f_(a){return new vt(function(e){var n,r;try{for(var o=kr(a),l=o.next();!l.done;l=o.next()){var u=l.value;if(e.next(u),e.closed)return}}catch(d){n={error:d}}finally{try{l&&!l.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}e.complete()})}function xb(a){return new vt(function(e){m_(a,e).catch(function(n){return e.error(n)})})}function h_(a){return xb(Mb(a))}function m_(a,e){var n,r,o,l;return qR(this,void 0,void 0,function(){var u,d;return yb(this,function(h){switch(h.label){case 0:h.trys.push([0,5,6,11]),n=HR(a),h.label=1;case 1:return[4,n.next()];case 2:if(r=h.sent(),!!r.done)return[3,4];if(u=r.value,e.next(u),e.closed)return[2];h.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return d=h.sent(),o={error:d},[3,11];case 6:return h.trys.push([6,,9,10]),r&&!r.done&&(l=n.return)?[4,l.call(n)]:[3,8];case 7:h.sent(),h.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function ga(a,e,n,r,o){r===void 0&&(r=0),o===void 0&&(o=!1);var l=e.schedule(function(){n(),o?a.add(this.schedule(null,r)):this.unsubscribe()},r);if(a.add(l),!o)return l}function Nb(a,e){return e===void 0&&(e=0),Sa(function(n,r){n.subscribe(Fs(r,function(o){return ga(r,a,function(){return r.next(o)},e)},function(){return ga(r,a,function(){return r.complete()},e)},function(o){return ga(r,a,function(){return r.error(o)},e)}))})}function Ub(a,e){return e===void 0&&(e=0),Sa(function(n,r){r.add(a.schedule(function(){return n.subscribe(r)},e))})}function p_(a,e){return Qs(a).pipe(Ub(e),Nb(e))}function g_(a,e){return Qs(a).pipe(Ub(e),Nb(e))}function v_(a,e){return new vt(function(n){var r=0;return e.schedule(function(){r===a.length?n.complete():(n.next(a[r++]),n.closed||this.schedule())})})}function y_(a,e){return new vt(function(n){var r;return ga(n,e,function(){r=a[Db](),ga(n,e,function(){var o,l,u;try{o=r.next(),l=o.value,u=o.done}catch(d){n.error(d);return}u?n.complete():n.next(l)},0,!0)}),function(){return dt(r==null?void 0:r.return)&&r.return()}})}function Lb(a,e){if(!a)throw new Error("Iterable cannot be null");return new vt(function(n){ga(n,e,function(){var r=a[Symbol.asyncIterator]();ga(n,e,function(){r.next().then(function(o){o.done?n.complete():n.next(o.value)})},0,!0)})})}function b_(a,e){return Lb(Mb(a),e)}function S_(a,e){if(a!=null){if(_b(a))return p_(a,e);if(Eb(a))return v_(a,e);if(Rb(a))return g_(a,e);if(wb(a))return Lb(a,e);if(Ab(a))return y_(a,e);if(Pb(a))return b_(a,e)}throw Ob(a)}function T_(a,e){return e?S_(a,e):Qs(a)}eh(function(a){return function(e){e===void 0&&(e=null),a(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=e}});function Ft(a,e){return Sa(function(n,r){var o=0;n.subscribe(Fs(r,function(l){r.next(a.call(e,l,o++))}))})}function k_(a,e,n,r,o,l,u,d){var h=[],m=0,g=0,y=!1,b=function(){y&&!h.length&&!m&&e.complete()},T=function(k){return m<r?C(k):h.push(k)},C=function(k){m++;var w=!1;Qs(n(k,g++)).subscribe(Fs(e,function(O){e.next(O)},function(){w=!0},void 0,function(){if(w)try{m--;for(var O=function(){var V=h.shift();u||C(V)};h.length&&m<r;)O();b()}catch(V){e.error(V)}}))};return a.subscribe(Fs(e,T,function(){y=!0,b()})),function(){}}function Ib(a,e,n){return n===void 0&&(n=1/0),dt(e)?Ib(function(r,o){return Ft(function(l,u){return e(r,l,o,u)})(Qs(a(r,o)))},n):(typeof e=="number"&&(n=e),Sa(function(r,o){return k_(r,o,a,n)}))}function C_(a){return Ib(kb,a)}function E_(){return C_(1)}function Of(){for(var a=[],e=0;e<arguments.length;e++)a[e]=arguments[e];return E_()(T_(a,Cb(a)))}function R_(a,e){return Sa(function(n,r){var o=0;n.subscribe(Fs(r,function(l){return a.call(e,l,o++)&&r.next(l)}))})}function __(a){return Sa(function(e,n){try{e.subscribe(n)}finally{n.add(a)}})}function Nn(){for(var a=[],e=0;e<arguments.length;e++)a[e]=arguments[e];var n=Cb(a);return Sa(function(r,o){(n?Of(a,r,n):Of(a,r)).subscribe(o)})}var w_=Object.defineProperty,O_=Object.defineProperties,D_=Object.getOwnPropertyDescriptors,d0=Object.getOwnPropertySymbols,A_=Object.prototype.hasOwnProperty,M_=Object.prototype.propertyIsEnumerable,f0=(a,e,n)=>e in a?w_(a,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[e]=n,Df=(a,e)=>{for(var n in e||(e={}))A_.call(e,n)&&f0(a,n,e[n]);if(d0)for(var n of d0(e))M_.call(e,n)&&f0(a,n,e[n]);return a},P_=(a,e)=>O_(a,D_(e)),Ta=(a,e,n)=>new Promise((r,o)=>{var l=h=>{try{d(n.next(h))}catch(m){o(m)}},u=h=>{try{d(n.throw(h))}catch(m){o(m)}},d=h=>h.done?r(h.value):Promise.resolve(h.value).then(l,u);d((n=n.apply(a,e)).next())}),jb="lk";function ih(a){return typeof a>"u"?!1:x_(a)||N_(a)}function x_(a){var e;return a?a.hasOwnProperty("participant")&&a.hasOwnProperty("source")&&a.hasOwnProperty("track")&&typeof((e=a.publication)==null?void 0:e.track)<"u":!1}function N_(a){return a?a.hasOwnProperty("participant")&&a.hasOwnProperty("source")&&a.hasOwnProperty("publication")&&typeof a.publication<"u":!1}function U_(a){return a?a.hasOwnProperty("participant")&&a.hasOwnProperty("source")&&typeof a.publication>"u":!1}function Bb(a){if(typeof a=="string"||typeof a=="number")return`${a}`;if(U_(a))return`${a.participant.identity}_${a.source}_placeholder`;if(ih(a))return`${a.participant.identity}_${a.publication.source}_${a.publication.trackSid}`;throw new Error(`Can't generate a id for the given track reference: ${a}`)}function L_(a,e){return Ta(this,null,function*(){const{x:n,y:r}=yield IR(a,e,{placement:"top",middleware:[NR(6),LR(),UR({padding:5})]});return{x:n,y:r}})}function I_(a,e){return!a.contains(e.target)}var j_=[B.ConnectionStateChanged,B.RoomMetadataChanged,B.ActiveSpeakersChanged,B.ConnectionQualityChanged,B.ParticipantConnected,B.ParticipantDisconnected,B.ParticipantPermissionsChanged,B.ParticipantMetadataChanged,B.ParticipantNameChanged,B.ParticipantAttributesChanged,B.TrackMuted,B.TrackUnmuted,B.TrackPublished,B.TrackUnpublished,B.TrackStreamStateChanged,B.TrackSubscriptionFailed,B.TrackSubscriptionPermissionChanged,B.TrackSubscriptionStatusChanged],zb=[...j_,B.LocalTrackPublished,B.LocalTrackUnpublished],B_=[F.TrackPublished,F.TrackUnpublished,F.TrackMuted,F.TrackUnmuted,F.TrackStreamStateChanged,F.TrackSubscribed,F.TrackUnsubscribed,F.TrackSubscriptionPermissionChanged,F.TrackSubscriptionFailed,F.LocalTrackPublished,F.LocalTrackUnpublished],z_=[F.ConnectionQualityChanged,F.IsSpeakingChanged,F.ParticipantMetadataChanged,F.ParticipantPermissionsChanged,F.TrackMuted,F.TrackUnmuted,F.TrackPublished,F.TrackUnpublished,F.TrackStreamStateChanged,F.TrackSubscriptionFailed,F.TrackSubscriptionPermissionChanged,F.TrackSubscriptionStatusChanged];[...z_,F.LocalTrackPublished,F.LocalTrackUnpublished];var Ae=zR.getLogger("lk-components-js");Ae.setDefaultLevel("WARN");function q_(a,e){var n;return P_(Df({},a),{receivedAtMediaTimestamp:(n=e.rtpTimestamp)!=null?n:0,receivedAt:e.timestamp})}function V_(a,e,n){return[...a,...e].reduceRight((r,o)=>(r.find(l=>l.id===o.id)||r.unshift(o),r),[]).slice(0-n)}function qb(a){return typeof a=="object"}function Vb(a){return Array.isArray(a)&&a.filter(qb).length>0}function ka(a){return`${jb}-${a}`}function H_(a){const e=Af(a),n=ah(a.participant).pipe(Ft(()=>Af(a)),Nn(e));return{className:ka(a.source===j.Source.Camera||a.source===j.Source.ScreenShare?"participant-media-video":"participant-media-audio"),trackObserver:n}}function Af(a){if(ih(a))return a.publication;{const{source:e,name:n,participant:r}=a;if(e&&n)return r.getTrackPublications().find(o=>o.source===e&&o.trackName===n);if(n)return r.getTrackPublicationByName(n);if(e)return r.getTrackPublication(e);throw new Error("At least one of source and name needs to be defined")}}function nl(a,...e){return new vt(n=>{const r=()=>{n.next(a)};return e.forEach(o=>{a.on(o,r)}),()=>{e.forEach(o=>{a.off(o,r)})}}).pipe(Nn(a))}function Hb(a,e){return new vt(n=>{const r=(...o)=>{n.next(o)};return a.on(e,r),()=>{a.off(e,r)}})}function G_(a){return Hb(a,B.ConnectionStateChanged).pipe(Ft(([e])=>e),Nn(a.state))}function F_(a,e,n=!0){var r;const o=()=>Ta(this,null,function*(){try{const d=yield ni.getLocalDevices(a,n);l.next(d)}catch(d){e==null||e(d)}}),l=new Cr,u=l.pipe(__(()=>{var d;(d=navigator==null?void 0:navigator.mediaDevices)==null||d.removeEventListener("devicechange",o)}));if(typeof window<"u"){if(!window.isSecureContext)throw new Error("Accessing media devices is available only in secure contexts (HTTPS and localhost), in some or all supporting browsers. See: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/mediaDevices");(r=navigator==null?void 0:navigator.mediaDevices)==null||r.addEventListener("devicechange",o)}return Of(ni.getLocalDevices(a,n).catch(d=>(e==null||e(d),[])),u)}function Y_(a){return nl(a,B.AudioPlaybackStatusChanged).pipe(Ft(e=>({canPlayAudio:e.canPlaybackAudio})))}function K_(a){return nl(a,B.VideoPlaybackStatusChanged).pipe(Ft(e=>({canPlayVideo:e.canPlaybackVideo})))}function Q_(a,e){return Hb(a,B.ActiveDeviceChanged).pipe(R_(([n])=>n===e),Ft(([n,r])=>(Ae.debug("activeDeviceObservable | RoomEvent.ActiveDeviceChanged",{kind:n,deviceId:r}),r)))}function Gb(a,...e){return new vt(n=>{const r=()=>{n.next(a)};return e.forEach(o=>{a.on(o,r)}),()=>{e.forEach(o=>{a.off(o,r)})}}).pipe(Nn(a))}function ah(a){return Gb(a,F.TrackMuted,F.TrackUnmuted,F.ParticipantPermissionsChanged,F.TrackPublished,F.TrackUnpublished,F.LocalTrackPublished,F.LocalTrackUnpublished,F.MediaDevicesError,F.TrackSubscriptionStatusChanged).pipe(Ft(e=>{const{isMicrophoneEnabled:n,isCameraEnabled:r,isScreenShareEnabled:o}=e,l=e.getTrackPublication(j.Source.Microphone),u=e.getTrackPublication(j.Source.Camera);return{isCameraEnabled:r,isMicrophoneEnabled:n,isScreenShareEnabled:o,cameraTrack:u,microphoneTrack:l,participant:e}}))}function Fb(a,e){return new vt(n=>{const r=(...o)=>{n.next(o)};return a.on(e,r),()=>{a.off(e,r)}})}function X_(a,e={}){var n;let r;const o=new vt(h=>(r=h,()=>d.unsubscribe())).pipe(Nn(Array.from(a.remoteParticipants.values()))),l=(n=e.additionalRoomEvents)!=null?n:zb,u=Array.from(new Set([B.ParticipantConnected,B.ParticipantDisconnected,B.ConnectionStateChanged,...l])),d=nl(a,...u).subscribe(h=>r==null?void 0:r.next(Array.from(h.remoteParticipants.values())));return a.remoteParticipants.size>0&&(r==null||r.next(Array.from(a.remoteParticipants.values()))),o}function Z_(a){return Fb(a,F.ParticipantPermissionsChanged).pipe(Ft(()=>a.permissions),Nn(a.permissions))}function h0(a){return typeof a>"u"?new vt:Fb(a,F.AttributesChanged).pipe(Ft(([e])=>({changed:e,attributes:a.attributes})),Nn({changed:a.attributes,attributes:a.attributes}))}function J_(a,e,n,r,o){const{localParticipant:l}=e,u=(g,y)=>{let b=!1;switch(g){case j.Source.Camera:b=y.isCameraEnabled;break;case j.Source.Microphone:b=y.isMicrophoneEnabled;break;case j.Source.ScreenShare:b=y.isScreenShareEnabled;break}return b},d=ah(l).pipe(Ft(g=>u(a,g.participant)),Nn(u(a,l))),h=new Cr,m=(g,y)=>Ta(this,null,function*(){try{switch(y??(y=n),h.next(!0),a){case j.Source.Camera:return yield l.setCameraEnabled(g??!l.isCameraEnabled,y,r),l.isCameraEnabled;case j.Source.Microphone:return yield l.setMicrophoneEnabled(g??!l.isMicrophoneEnabled,y,r),l.isMicrophoneEnabled;case j.Source.ScreenShare:return yield l.setScreenShareEnabled(g??!l.isScreenShareEnabled,y,r),l.isScreenShareEnabled;default:throw new TypeError("Tried to toggle unsupported source")}}catch(b){if(o&&b instanceof Error){o==null||o(b);return}else throw b}finally{h.next(!1)}});return{className:ka("button"),toggle:m,enabledObserver:d,pendingObserver:h.asObservable()}}function W_(){let a=!1;const e=new Cr,n=new Cr,r=o=>Ta(this,null,function*(){n.next(!0),a=o??!a,e.next(a),n.next(!1)});return{className:ka("button"),toggle:r,enabledObserver:e.asObservable(),pendingObserver:n.asObservable()}}function $_(a,e,n){const r=new t_(void 0),o=Q_(e,a),l=(u,...d)=>Ta(this,[u,...d],function*(h,m={}){var g,y,b;if(e){Ae.debug(`Switching active device of kind "${a}" with id ${h}.`),yield e.switchActiveDevice(a,h,m.exact);const T=(g=e.getActiveDevice(a))!=null?g:h;T!==h&&h!=="default"&&Ae.info(`We tried to select the device with id (${h}), but the browser decided to select the device with id (${T}) instead.`);let C;a==="audioinput"?C=(y=e.localParticipant.getTrackPublication(j.Source.Microphone))==null?void 0:y.track:a==="videoinput"&&(C=(b=e.localParticipant.getTrackPublication(j.Source.Camera))==null?void 0:b.track);const k=h==="default"&&!C||h==="default"&&(C==null?void 0:C.mediaStreamTrack.label.startsWith("Default"));r.next(k?h:T)}});return{className:ka("media-device-select"),activeDeviceObservable:o,setActiveMediaDevice:l}}function ew(a){const e=n=>{a.disconnect(n)};return{className:ka("disconnect-button"),disconnect:e}}new TextEncoder;new TextDecoder;function tw(){const a=e=>Ta(this,null,function*(){Ae.info("Start Audio for room: ",e),yield e.startAudio()});return{className:ka("start-audio-button"),roomAudioPlaybackAllowedObservable:Y_,handleStartAudioPlayback:a}}function nw(){const a=e=>Ta(this,null,function*(){Ae.info("Start Video for room: ",e),yield e.startVideo()});return{className:ka("start-audio-button"),roomVideoPlaybackAllowedObservable:K_,handleStartVideoPlayback:a}}function iw(){return{className:"lk-room-container"}}function m0(a,e,n=!0){const r=[a.localParticipant,...Array.from(a.remoteParticipants.values())],o=[];return r.forEach(l=>{e.forEach(u=>{const d=Array.from(l.trackPublications.values()).filter(h=>h.source===u&&(!n||h.track)).map(h=>({participant:l,publication:h,source:h.source}));o.push(...d)})}),{trackReferences:o,participants:r}}function p0(a,e,n=!1){const{sources:r,kind:o,name:l}=e;return Array.from(a.trackPublications.values()).filter(u=>(!r||r.includes(u.source))&&(!o||u.kind===o)&&(!l||u.trackName===l)&&(!n||u.track)).map(u=>({participant:a,publication:u,source:u.source}))}function aw(a,e,n){var r,o;const l=(r=n.additionalRoomEvents)!=null?r:zb,u=(o=n.onlySubscribed)!=null?o:!0,d=Array.from(new Set([B.ParticipantConnected,B.ParticipantDisconnected,B.ConnectionStateChanged,B.LocalTrackPublished,B.LocalTrackUnpublished,B.TrackPublished,B.TrackUnpublished,B.TrackSubscriptionStatusChanged,...l]).values());return nl(a,...d).pipe(Ft(h=>{const m=m0(h,e,u);return Ae.debug(`TrackReference[] was updated. (length ${m.trackReferences.length})`,m),m}),Nn(m0(a,e,u)))}function rw(a,e){return Gb(a,...B_).pipe(Ft(n=>{const r=p0(n,e);return Ae.debug(`TrackReference[] was updated. (length ${r.length})`,r),r}),Nn(p0(a,e)))}function Yb(a,e){return new vt(n=>{const r=(...o)=>{n.next(o)};return a.on(e,r),()=>{a.off(e,r)}})}function sw(a){return Yb(a,W.TranscriptionReceived)}function ow(a){return Yb(a,W.TimeSyncUpdate).pipe(Ft(([e])=>e))}function cw(a,e){if(typeof localStorage>"u"){Ae.error("Local storage is not available.");return}try{if(e){const n=Object.fromEntries(Object.entries(e).filter(([,r])=>r!==""));localStorage.setItem(a,JSON.stringify(n))}}catch(n){Ae.error(`Error setting item to local storage: ${n}`)}}function lw(a){if(typeof localStorage>"u"){Ae.error("Local storage is not available.");return}try{const e=localStorage.getItem(a);if(!e){Ae.warn(`Item with key ${a} does not exist in local storage.`);return}return JSON.parse(e)}catch(e){Ae.error(`Error getting item from local storage: ${e}`);return}}function uw(a){return{load:()=>lw(a),save:e=>cw(a,e)}}var dw=`${jb}-user-choices`,Ps={videoEnabled:!0,audioEnabled:!0,videoDeviceId:"default",audioDeviceId:"default",username:""},{load:fw,save:hw}=uw(dw);function mw(a,e=!1){e!==!0&&hw(a)}function pw(a,e=!1){var n,r,o,l,u;const d={videoEnabled:(n=a==null?void 0:a.videoEnabled)!=null?n:Ps.videoEnabled,audioEnabled:(r=a==null?void 0:a.audioEnabled)!=null?r:Ps.audioEnabled,videoDeviceId:(o=a==null?void 0:a.videoDeviceId)!=null?o:Ps.videoDeviceId,audioDeviceId:(l=a==null?void 0:a.audioDeviceId)!=null?l:Ps.audioDeviceId,username:(u=a==null?void 0:a.username)!=null?u:Ps.username};if(e)return d;{const h=fw();return Df(Df({},d),h??{})}}P.createContext(void 0);const gw=P.createContext(void 0);function Kb(){return P.useContext(gw)}function vw(a){const e=Kb(),n=a??e;if(!n)throw new Error("No TrackRef, make sure you are inside a TrackRefContext or pass the TrackRef explicitly");return n}const yw=P.createContext(void 0);function Qb(){return P.useContext(yw)}const rh=P.createContext(void 0);function il(){const a=P.useContext(rh);if(!a)throw Error("tried to access room context outside of livekit room component");return a}function al(){return P.useContext(rh)}function _r(a){const e=al(),n=a??e;if(!n)throw new Error("No room provided, make sure you are inside a Room context or pass the room explicitly");return n}const bw=P.createContext(void 0);function Xb(a){var e,n,r="";if(typeof a=="string"||typeof a=="number")r+=a;else if(typeof a=="object")if(Array.isArray(a)){var o=a.length;for(e=0;e<o;e++)a[e]&&(n=Xb(a[e]))&&(r&&(r+=" "),r+=n)}else for(n in a)a[n]&&(r&&(r+=" "),r+=n);return r}function Zb(){for(var a,e,n=0,r="",o=arguments.length;n<o;n++)(a=arguments[n])&&(e=Xb(a))&&(r&&(r+=" "),r+=e);return r}function Sw(...a){return(...e)=>{for(const n of a)if(typeof n=="function")try{n(...e)}catch(r){console.error(r)}}}function wr(...a){const e={...a[0]};for(let n=1;n<a.length;n++){const r=a[n];for(const o in r){const l=e[o],u=r[o];typeof l=="function"&&typeof u=="function"&&o[0]==="o"&&o[1]==="n"&&o.charCodeAt(2)>=65&&o.charCodeAt(2)<=90?e[o]=Sw(l,u):(o==="className"||o==="UNSAFE_className")&&typeof l=="string"&&typeof u=="string"?e[o]=Zb(l,u):e[o]=u!==void 0?u:l}}return e}function Tw(a){return a!==void 0}function rl(...a){return wr(...a.filter(Tw))}function kw(a,e,n){return P.Children.map(a,r=>P.isValidElement(r)&&P.Children.only(a)?(r.props.class&&(e??(e={}),e.class=Zb(r.props.class,e.class),e.style={...r.props.style,...e.style}),P.cloneElement(r,{...e,key:n})):r)}function Cw(a,e){return a==="processor"&&e&&typeof e=="object"&&"name"in e?e.name:a==="e2ee"&&e?"e2ee-enabled":e}const Ew={connect:!0,audio:!1,video:!1};function Rw(a){const{token:e,serverUrl:n,options:r,room:o,connectOptions:l,connect:u,audio:d,video:h,screen:m,onConnected:g,onDisconnected:y,onError:b,onMediaDeviceFailure:T,onEncryptionError:C,simulateParticipants:k,...w}={...Ew,...a};r&&o&&Ae.warn("when using a manually created room, the options object will be ignored. set the desired options directly when creating the room instead.");const[O,V]=P.useState(),Q=P.useRef(u);P.useEffect(()=>{V(o??new ni(r))},[o,JSON.stringify(r,Cw)]);const U=P.useMemo(()=>{const{className:_}=iw();return wr(w,{className:_})},[w]);return P.useEffect(()=>{if(!O)return;const _=()=>{const J=O.localParticipant;Ae.debug("trying to publish local tracks"),Promise.all([J.setMicrophoneEnabled(!!d,typeof d!="boolean"?d:void 0),J.setCameraEnabled(!!h,typeof h!="boolean"?h:void 0),J.setScreenShareEnabled(!!m,typeof m!="boolean"?m:void 0)]).catch(ee=>{Ae.warn(ee),b==null||b(ee)})},H=J=>{const ee=Vs.getFailure(J);T==null||T(ee)},$=J=>{C==null||C(J)},ie=J=>{y==null||y(J)},X=()=>{g==null||g()};return O.on(B.SignalConnected,_).on(B.MediaDevicesError,H).on(B.EncryptionError,$).on(B.Disconnected,ie).on(B.Connected,X),()=>{O.off(B.SignalConnected,_).off(B.MediaDevicesError,H).off(B.EncryptionError,$).off(B.Disconnected,ie).off(B.Connected,X)}},[O,d,h,m,b,C,T,g,y]),P.useEffect(()=>{if(O){if(k){O.simulateParticipants({participants:{count:k},publish:{audio:!0,useRealTracks:!0}});return}if(u){if(Q.current=!0,Ae.debug("connecting"),!e){Ae.debug("no token yet");return}if(!n){Ae.warn("no livekit url provided"),b==null||b(Error("no livekit url provided"));return}O.connect(n,e,l).catch(_=>{Ae.warn(_),Q.current===!0&&(b==null||b(_))})}else Ae.debug("disconnecting because connect is false"),Q.current=!1,O.disconnect()}},[u,e,JSON.stringify(l),O,b,n,k]),P.useEffect(()=>{if(O)return()=>{Ae.info("disconnecting on onmount"),O.disconnect()}},[O]),{room:O,htmlProps:U}}const _w=P.forwardRef(function(a,e){const{room:n,htmlProps:r}=Rw(a);return P.createElement("div",{ref:e,...r},n&&P.createElement(rh.Provider,{value:n},P.createElement(bw.Provider,{value:a.featureFlags},a.children)))});function Pn(a,e,n=!0){const[r,o]=P.useState(e);return P.useEffect(()=>{if(n&&o(e),typeof window>"u"||!a)return;const l=a.subscribe(o);return()=>l.unsubscribe()},[a,n]),r}function sh(a){const e=_r(a),n=P.useMemo(()=>G_(e),[e]);return Pn(n,e.state)}function ww(a){const e=il(),n=sh(e);return{buttonProps:P.useMemo(()=>{const{className:r,disconnect:o}=ew(e);return wr(a,{className:r,onClick:()=>o(a.stopTracks??!0),disabled:n===Te.Disconnected})},[e,a,n])}}function Ow(a={}){const e=_r(a.room),[n,r]=P.useState(e.localParticipant),[o,l]=P.useState(n.isMicrophoneEnabled),[u,d]=P.useState(n.isMicrophoneEnabled),[h,m]=P.useState(n.lastMicrophoneError),[g,y]=P.useState(n.lastCameraError),[b,T]=P.useState(n.isMicrophoneEnabled),[C,k]=P.useState(void 0),[w,O]=P.useState(void 0),V=Q=>{d(Q.isCameraEnabled),l(Q.isMicrophoneEnabled),T(Q.isScreenShareEnabled),O(Q.cameraTrack),k(Q.microphoneTrack),m(Q.participant.lastMicrophoneError),y(Q.participant.lastCameraError),r(Q.participant)};return P.useEffect(()=>{const Q=ah(e.localParticipant).subscribe(V);return()=>Q.unsubscribe()},[e]),{isMicrophoneEnabled:o,isScreenShareEnabled:b,isCameraEnabled:u,microphoneTrack:C,cameraTrack:w,lastMicrophoneError:h,lastCameraError:g,localParticipant:n}}function Dw(){const a=il(),e=P.useMemo(()=>Z_(a.localParticipant),[a]);return Pn(e,a.localParticipant.permissions)}function Aw({kind:a,room:e,track:n,requestPermissions:r,onError:o}){const l=al(),u=P.useMemo(()=>e??l??new ni,[e,l]),d=P.useMemo(()=>F_(a,o,r),[a,r,o]),h=Pn(d,[]),[m,g]=P.useState((u==null?void 0:u.getActiveDevice(a))??"default"),{className:y,activeDeviceObservable:b,setActiveMediaDevice:T}=P.useMemo(()=>$_(a,u),[a,u,n]);return P.useEffect(()=>{const C=b.subscribe(k=>{k&&(Ae.info("setCurrentDeviceId",k),g(k))});return()=>{C==null||C.unsubscribe()}},[b]),{devices:h,className:y,activeDeviceId:m,setActiveMediaDevice:T}}function Mw(a={}){const e=_r(a.room),[n,r]=P.useState([]);return P.useEffect(()=>{const o=X_(e,{additionalRoomEvents:a.updateOnlyOn}).subscribe(r);return()=>o.unsubscribe()},[e,JSON.stringify(a.updateOnlyOn)]),n}function Jb({room:a,props:e}){const n=_r(a),{className:r,roomAudioPlaybackAllowedObservable:o,handleStartAudioPlayback:l}=P.useMemo(()=>tw(),[]),u=P.useMemo(()=>o(n),[n,o]),{canPlayAudio:d}=Pn(u,{canPlayAudio:n.canPlaybackAudio});return{mergedProps:P.useMemo(()=>wr(e,{className:r,onClick:()=>{l(n)},style:{display:d?"none":"block"}}),[e,r,d,l,n]),canPlayAudio:d}}function Pw({room:a,props:e}){const n=_r(a),{className:r,roomVideoPlaybackAllowedObservable:o,handleStartVideoPlayback:l}=P.useMemo(()=>nw(),[]),u=P.useMemo(()=>o(n),[n,o]),{canPlayVideo:d}=Pn(u,{canPlayVideo:n.canPlaybackVideo});return{mergedProps:P.useMemo(()=>wr(e,{className:r,onClick:()=>{l(n)},style:{display:d?"none":"block"}}),[e,r,d,l,n]),canPlayVideo:d}}function xw({source:a,onChange:e,initialState:n,captureOptions:r,publishOptions:o,onDeviceError:l,...u}){var d;const h=al(),m=(d=h==null?void 0:h.localParticipant)==null?void 0:d.getTrackPublication(a),g=P.useRef(!1),{toggle:y,className:b,pendingObserver:T,enabledObserver:C}=P.useMemo(()=>h?J_(a,h,r,o,l):W_(),[h,a,JSON.stringify(r),o]),k=Pn(T,!1),w=Pn(C,n??!!(m!=null&&m.isEnabled));P.useEffect(()=>{e==null||e(w,g.current),g.current=!1},[w,e]),P.useEffect(()=>{n!==void 0&&(Ae.debug("forcing initial toggle state",a,n),y(n))},[]);const O=P.useMemo(()=>wr(u,{className:b}),[u,b]),V=P.useCallback(Q=>{var U;g.current=!0,y().catch(()=>g.current=!1),(U=u.onClick)==null||U.call(u,Q)},[u,y]);return{toggle:y,enabled:w,pending:k,track:m,buttonProps:{...O,"aria-pressed":w,"data-lk-source":a,"data-lk-enabled":w,disabled:k,onClick:V}}}function Nw(a=[j.Source.Camera,j.Source.Microphone,j.Source.ScreenShare,j.Source.ScreenShareAudio,j.Source.Unknown],e={}){const n=_r(e.room),[r,o]=P.useState([]),[l,u]=P.useState([]),d=P.useMemo(()=>a.map(h=>qb(h)?h.source:h),[JSON.stringify(a)]);return P.useEffect(()=>{const h=aw(n,d,{additionalRoomEvents:e.updateOnlyOn,onlySubscribed:e.onlySubscribed}).subscribe(({trackReferences:m,participants:g})=>{Ae.debug("setting track bundles",m,g),o(m),u(g)});return()=>h.unsubscribe()},[n,JSON.stringify(e.onlySubscribed),JSON.stringify(e.updateOnlyOn),JSON.stringify(a)]),P.useMemo(()=>{if(Vb(a)){const h=Lw(a,l),m=Array.from(r);return l.forEach(g=>{h.has(g.identity)&&(h.get(g.identity)??[]).forEach(y=>{if(r.find(({participant:T,publication:C})=>g.identity===T.identity&&C.source===y))return;Ae.debug(`Add ${y} placeholder for participant ${g.identity}.`);const b={participant:g,source:y};m.push(b)})}),m}else return r},[r,l,a])}function Uw(a,e){const n=new Set(a);for(const r of e)n.delete(r);return n}function Lw(a,e){const n=new Map;if(Vb(a)){const r=a.filter(o=>o.withPlaceholder).map(o=>o.source);e.forEach(o=>{const l=o.getTrackPublications().map(d=>{var h;return(h=d.track)==null?void 0:h.source}).filter(d=>d!==void 0),u=Array.from(Uw(new Set(r),new Set(l)));u.length>0&&n.set(o.identity,u)})}return n}function Iw(a={}){const[e,n]=P.useState(pw(a.defaults,a.preventLoad??!1)),r=P.useCallback(h=>{n(m=>({...m,audioEnabled:h}))},[]),o=P.useCallback(h=>{n(m=>({...m,videoEnabled:h}))},[]),l=P.useCallback(h=>{n(m=>({...m,audioDeviceId:h}))},[]),u=P.useCallback(h=>{n(m=>({...m,videoDeviceId:h}))},[]),d=P.useCallback(h=>{n(m=>({...m,username:h}))},[]);return P.useEffect(()=>{mw(e,a.preventSave??!1)},[e,a.preventSave]),{userChoices:e,saveAudioInputEnabled:r,saveVideoInputEnabled:o,saveAudioInputDeviceId:l,saveVideoInputDeviceId:u,saveUsername:d}}const jw=a=>{const e=n=>{let r=1-Math.max(-100,Math.min(-10,n))*-1/100;return r=Math.sqrt(r),r};return a.map(n=>n===-1/0?0:e(n))},Bw={bands:5,loPass:100,hiPass:600,updateInterval:32,analyserOptions:{fftSize:2048}};function zw(a,e={}){var n;const r=a instanceof j?a:(n=a==null?void 0:a.publication)==null?void 0:n.track,o={...Bw,...e},[l,u]=P.useState(new Array(o.bands).fill(0));return P.useEffect(()=>{if(!r||!(r!=null&&r.mediaStream))return;const{analyser:d,cleanup:h}=QE(r,o.analyserOptions),m=d.frequencyBinCount,g=new Float32Array(m),y=setInterval(()=>{d.getFloatFrequencyData(g);let b=new Float32Array(g.length);for(let w=0;w<g.length;w++)b[w]=g[w];b=b.slice(e.loPass,e.hiPass);const T=jw(b),C=Math.ceil(T.length/o.bands),k=[];for(let w=0;w<o.bands;w++){const O=T.slice(w*C,(w+1)*C).reduce((V,Q)=>V+=Q,0);k.push(O/C)}u(k)},o.updateInterval);return()=>{h(),clearInterval(y)}},[r,r==null?void 0:r.mediaStream,JSON.stringify(e)]),l}function qw(a,e){const n=il(),r=Qb(),o=e?n.getParticipantByIdentity(e):r,l=P.useMemo(()=>o?rw(o,{sources:a}):void 0,[o==null?void 0:o.sid,o==null?void 0:o.identity,JSON.stringify(a)]);return Pn(l,[])}function Vw(a){var e,n,r;const o=P.useMemo(()=>{var l;return(l=a==null?void 0:a.publication)!=null&&l.track?ow(a==null?void 0:a.publication.track):void 0},[(e=a==null?void 0:a.publication)==null?void 0:e.track]);return Pn(o,{timestamp:Date.now(),rtpTimestamp:(r=(n=a==null?void 0:a.publication)==null?void 0:n.track)==null?void 0:r.rtpTimestamp})}const Hw={bufferSize:100};function Gw(a,e){const n={...Hw,...e},[r,o]=P.useState([]),l=Vw(a),u=d=>{var h;(h=n.onTranscription)==null||h.call(n,d),o(m=>V_(m,d.map(g=>q_(g,l)),n.bufferSize))};return P.useEffect(()=>{if(!(a!=null&&a.publication))return;const d=sw(a.publication).subscribe(h=>{u(...h)});return()=>{d.unsubscribe()}},[a&&Bb(a),u]),{segments:r}}function Fw(a={}){const e=Qb(),n=a.participant??e,r=P.useMemo(()=>h0(n),[n]);return Pn(r,{attributes:n==null?void 0:n.attributes})}const g0="lk.agent.state";function Yw(){const a=Mw().find(u=>u.kind===qs.AGENT),e=qw([j.Source.Microphone],a==null?void 0:a.identity)[0],{segments:n}=Gw(e),r=sh(),{attributes:o}=Fw({participant:a}),l=P.useMemo(()=>r===Te.Disconnected?"disconnected":r===Te.Connecting||!a||!(o!=null&&o[g0])?"connecting":o[g0],[o,a,r]);return{agent:a,state:l,audioTrack:e,agentTranscriptions:n,agentAttributes:o}}const Wb=P.forwardRef(function(a,e){const{buttonProps:n}=ww(a);return P.createElement("button",{ref:e,...n},a.children)}),Kw=a=>P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...a},P.createElement("path",{d:"M1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708L11 10.293V4.5A1.5 1.5 0 0 0 9.5 3H3.707zM0 4.5a1.5 1.5 0 0 1 .943-1.393l9.532 9.533c-.262.224-.603.36-.975.36h-8A1.5 1.5 0 0 1 0 11.5z"}),P.createElement("path",{d:"m15.2 3.6-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z"})),Qw=a=>P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...a},P.createElement("path",{d:"M0 4.5A1.5 1.5 0 0 1 1.5 3h8A1.5 1.5 0 0 1 11 4.5v7A1.5 1.5 0 0 1 9.5 13h-8A1.5 1.5 0 0 1 0 11.5zM15.2 3.6l-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z"})),Xw=a=>P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...a},P.createElement("path",{d:"M12.227 11.52a5.477 5.477 0 0 0 1.246-2.97.5.5 0 0 0-.995-.1 4.478 4.478 0 0 1-.962 2.359l-1.07-1.07C10.794 9.247 11 8.647 11 8V3a3 3 0 0 0-6 0v1.293L1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708zM8 12.5c.683 0 1.33-.152 1.911-.425l.743.743c-.649.359-1.378.59-2.154.66V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .995-.098A4.5 4.5 0 0 0 8 12.5z"}),P.createElement("path",{d:"M8.743 10.907 5 7.164V8a3 3 0 0 0 3.743 2.907z"})),Zw=a=>P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...a},P.createElement("path",{fillRule:"evenodd",d:"M2.975 8.002a.5.5 0 0 1 .547.449 4.5 4.5 0 0 0 8.956 0 .5.5 0 1 1 .995.098A5.502 5.502 0 0 1 8.5 13.478V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .448-.547z",clipRule:"evenodd"}),P.createElement("path",{d:"M5 3a3 3 0 1 1 6 0v5a3 3 0 0 1-6 0z"})),Jw=a=>P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:16,fill:"none",...a},P.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M0 2.75A2.75 2.75 0 0 1 2.75 0h14.5A2.75 2.75 0 0 1 20 2.75v10.5A2.75 2.75 0 0 1 17.25 16H2.75A2.75 2.75 0 0 1 0 13.25V2.75ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h14.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z",clipRule:"evenodd"}),P.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M9.47 4.22a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1-1.06 1.06l-.97-.97v4.69a.75.75 0 0 1-1.5 0V6.56l-.97.97a.75.75 0 0 1-1.06-1.06l2.25-2.25Z",clipRule:"evenodd"})),Ww=a=>P.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:16,fill:"none",...a},P.createElement("g",{fill:"currentColor"},P.createElement("path",{d:"M7.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L10 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L11.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L10 6.94z"}),P.createElement("path",{fillRule:"evenodd",d:"M2.75 0A2.75 2.75 0 0 0 0 2.75v10.5A2.75 2.75 0 0 0 2.75 16h14.5A2.75 2.75 0 0 0 20 13.25V2.75A2.75 2.75 0 0 0 17.25 0zM1.5 2.75c0-.69.56-1.25 1.25-1.25h14.5c.69 0 1.25.56 1.25 1.25v10.5c0 .69-.56 1.25-1.25 1.25H2.75c-.69 0-1.25-.56-1.25-1.25z",clipRule:"evenodd"}))),qd=P.forwardRef(function({kind:a,initialSelection:e,onActiveDeviceChange:n,onDeviceListChange:r,onDeviceSelectError:o,exactMatch:l,track:u,requestPermissions:d,onError:h,...m},g){const y=al(),b=P.useCallback(_=>{y&&y.emit(B.MediaDevicesError,_),h==null||h(_)},[y,h]),{devices:T,activeDeviceId:C,setActiveMediaDevice:k,className:w}=Aw({kind:a,room:y,track:u,requestPermissions:d,onError:b});P.useEffect(()=>{e!==void 0&&k(e)},[k]),P.useEffect(()=>{typeof r=="function"&&r(T)},[r,T]),P.useEffect(()=>{C&&C!==""&&(n==null||n(C))},[C]);const O=async _=>{try{await k(_,{exact:l})}catch(H){if(H instanceof Error)o==null||o(H);else throw H}},V=P.useMemo(()=>rl(m,{className:w},{className:"lk-list"}),[w,m]),Q=!!T.find(_=>_.label.toLowerCase().startsWith("default"));function U(_,H,$){return _===H||!Q&&$===0&&H==="default"}return P.createElement("ul",{ref:g,...V},T.map((_,H)=>P.createElement("li",{key:_.deviceId,id:_.deviceId,"data-lk-active":U(_.deviceId,C,H),"aria-selected":U(_.deviceId,C,H),role:"option"},P.createElement("button",{className:"lk-button",onClick:()=>O(_.deviceId)},_.label))))}),$w=P.forwardRef(function({label:a,...e},n){const r=il(),{mergedProps:o,canPlayAudio:l}=Jb({room:r,props:e}),{mergedProps:u,canPlayVideo:d}=Pw({room:r,props:o}),{style:h,...m}=u;return h.display=l&&d?"none":"block",P.createElement("button",{ref:n,style:h,...m},a??`Start ${l?"Video":"Audio"}`)});function eO(a,e){switch(a){case j.Source.Microphone:return e?P.createElement(Zw,null):P.createElement(Xw,null);case j.Source.Camera:return e?P.createElement(Qw,null):P.createElement(Kw,null);case j.Source.ScreenShare:return e?P.createElement(Ww,null):P.createElement(Jw,null);default:return}}const tO=P.forwardRef(function({showIcon:a,...e},n){const{buttonProps:r,enabled:o}=xw(e),[l,u]=P.useState(!1);return P.useEffect(()=>{u(!0)},[]),l&&P.createElement("button",{ref:n,...r},(a??!0)&&eO(e.source,o),e.children)});function nO(a,e={}){const[n,r]=P.useState(Af(a)),[o,l]=P.useState(n==null?void 0:n.isMuted),[u,d]=P.useState(n==null?void 0:n.isSubscribed),[h,m]=P.useState(n==null?void 0:n.track),[g,y]=P.useState("landscape"),b=P.useRef(),{className:T,trackObserver:C}=P.useMemo(()=>H_(a),[a.participant.sid??a.participant.identity,a.source,ih(a)&&a.publication.trackSid]);return P.useEffect(()=>{const k=C.subscribe(w=>{Ae.debug("update track",w),r(w),l(w==null?void 0:w.isMuted),d(w==null?void 0:w.isSubscribed),m(w==null?void 0:w.track)});return()=>k==null?void 0:k.unsubscribe()},[C]),P.useEffect(()=>{var k,w;return h&&(b.current&&h.detach(b.current),(k=e.element)!=null&&k.current&&!(a.participant.isLocal&&(h==null?void 0:h.kind)==="audio")&&h.attach(e.element.current)),b.current=(w=e.element)==null?void 0:w.current,()=>{b.current&&(h==null||h.detach(b.current))}},[h,e.element]),P.useEffect(()=>{var k,w;if(typeof((k=n==null?void 0:n.dimensions)==null?void 0:k.width)=="number"&&typeof((w=n==null?void 0:n.dimensions)==null?void 0:w.height)=="number"){const O=n.dimensions.width>n.dimensions.height?"landscape":"portrait";y(O)}},[n]),{publication:n,isMuted:o,isSubscribed:u,track:h,elementProps:rl(e.props,{className:T,"data-lk-local-participant":a.participant.isLocal,"data-lk-source":n==null?void 0:n.source,...(n==null?void 0:n.kind)==="video"&&{"data-lk-orientation":g}})}}var iO=typeof Ns=="object"&&Ns&&Ns.Object===Object&&Ns,aO=typeof self=="object"&&self&&self.Object===Object&&self;iO||aO||Function("return this")();const rO=P.forwardRef(function({trackRef:a,onSubscriptionStatusChanged:e,volume:n,...r},o){const l=vw(a),u=P.useRef(null);P.useImperativeHandle(o,()=>u.current);const{elementProps:d,isSubscribed:h,track:m,publication:g}=nO(l,{element:u,props:r});return P.useEffect(()=>{e==null||e(!!h)},[h,e]),P.useEffect(()=>{m===void 0||n===void 0||(m instanceof eb?m.setVolume(n):Ae.warn("Volume can only be set on remote audio tracks."))},[n,m]),P.useEffect(()=>{g===void 0||r.muted===void 0||(g instanceof nb?g.setEnabled(!r.muted):Ae.warn("Can only call setEnabled on remote track publications."))},[r.muted,g,m]),P.createElement("audio",{ref:u,...d})});function sO({volume:a,muted:e}){const n=Nw([j.Source.Microphone,j.Source.ScreenShareAudio,j.Source.Unknown],{updateOnlyOn:[],onlySubscribed:!0}).filter(r=>!r.participant.isLocal&&r.publication.kind===j.Kind.Audio);return P.createElement("div",{style:{display:"none"}},n.map(r=>P.createElement(rO,{key:Bb(r),trackRef:r,volume:a,muted:e})))}const oO=a=>{const e=[];for(let n=0;n<a;n++)e.push([n,a-1-n]);return e},v0=a=>[[Math.floor(a/2)],[-1]],cO=(a,e,n)=>{const[r,o]=P.useState(0),[l,u]=P.useState([[]]);P.useEffect(()=>{if(a==="thinking")u(v0(e));else if(a==="connecting"||a==="initializing"){const h=[...oO(e)];u(h)}else u(a==="listening"?v0(e):a===void 0?[new Array(e).fill(0).map((h,m)=>m)]:[[]]);o(0)},[a,e]);const d=P.useRef(null);return P.useEffect(()=>{let h=performance.now();const m=g=>{g-h>=n&&(o(y=>y+1),h=g),d.current=requestAnimationFrame(m)};return d.current=requestAnimationFrame(m),()=>{d.current!==null&&cancelAnimationFrame(d.current)}},[n,e,a,l.length]),l[r%l.length]},lO=new Map([["connecting",2e3],["initializing",2e3],["listening",500],["thinking",150]]),uO=(a,e)=>{if(a===void 0)return 1e3;let n=lO.get(a);if(n)switch(a){case"connecting":n/=e;break}return n},$b=P.forwardRef(function({state:a,options:e,barCount:n=15,trackRef:r,children:o,...l},u){const d=rl(l,{className:"lk-audio-bar-visualizer"});let h=Kb();r&&(h=r);const m=zw(h,{bands:n,loPass:100,hiPass:200}),g=(e==null?void 0:e.minHeight)??20,y=(e==null?void 0:e.maxHeight)??100,b=cO(a,n,uO(a,n)??100);return P.createElement("div",{ref:u,...d,"data-lk-va-state":a},m.map((T,C)=>o?kw(o,{"data-lk-highlighted":b.includes(C),"data-lk-bar-index":C,className:"lk-audio-bar",style:{height:`${Math.min(y,Math.max(g,T*100+5))}%`}}):P.createElement("span",{key:C,"data-lk-highlighted":b.includes(C),"data-lk-bar-index":C,className:`lk-audio-bar ${b.includes(C)&&"lk-highlighted"}`,style:{height:`${Math.min(y,Math.max(g,T*100+5))}%`}})))});function dO({kind:a,initialSelection:e,onActiveDeviceChange:n,tracks:r,requestPermissions:o=!1,...l}){const[u,d]=P.useState(!1),[h,m]=P.useState([]),[g,y]=P.useState(!0),[b,T]=P.useState(o),C=(V,Q)=>{Ae.debug("handle device change"),d(!1),n==null||n(V,Q)},k=P.useRef(null),w=P.useRef(null);P.useLayoutEffect(()=>{u&&T(!0)},[u]),P.useLayoutEffect(()=>{k.current&&w.current&&(h||g)&&L_(k.current,w.current).then(({x:V,y:Q})=>{w.current&&Object.assign(w.current.style,{left:`${V}px`,top:`${Q}px`})}),y(!1)},[k,w,h,g]);const O=P.useCallback(V=>{w.current&&V.target!==k.current&&u&&I_(w.current,V)&&d(!1)},[u,w,k]);return P.useEffect(()=>(document.addEventListener("click",O),window.addEventListener("resize",()=>y(!0)),()=>{document.removeEventListener("click",O),window.removeEventListener("resize",()=>y(!0))}),[O,y]),P.createElement(P.Fragment,null,P.createElement("button",{className:"lk-button lk-button-menu","aria-pressed":u,...l,onClick:()=>d(!u),ref:k},l.children),!l.disabled&&P.createElement("div",{className:"lk-device-menu",ref:w,style:{visibility:u?"visible":"hidden"}},a?P.createElement(qd,{initialSelection:e,onActiveDeviceChange:V=>C(a,V),onDeviceListChange:m,kind:a,track:r==null?void 0:r[a],requestPermissions:b}):P.createElement(P.Fragment,null,P.createElement("div",{className:"lk-device-menu-heading"},"Audio inputs"),P.createElement(qd,{kind:"audioinput",onActiveDeviceChange:V=>C("audioinput",V),onDeviceListChange:m,track:r==null?void 0:r.audioinput,requestPermissions:b}),P.createElement("div",{className:"lk-device-menu-heading"},"Video inputs"),P.createElement(qd,{kind:"videoinput",onActiveDeviceChange:V=>C("videoinput",V),onDeviceListChange:m,track:r==null?void 0:r.videoinput,requestPermissions:b}))))}function fO({controls:a,saveUserChoices:e=!0,onDeviceError:n,...r}){const o={leave:!0,microphone:!0,...a},l=Dw(),{microphoneTrack:u,localParticipant:d}=Ow(),h=P.useMemo(()=>({participant:d,source:j.Source.Microphone,publication:u}),[d,u]);l?o.microphone??(o.microphone=l.canPublish):o.microphone=!1;const m=rl({className:"lk-agent-control-bar"},r),{saveAudioInputEnabled:g,saveAudioInputDeviceId:y}=Iw({preventSave:!e}),b=P.useCallback((T,C)=>{C&&g(T)},[g]);return P.createElement("div",{...m},o.microphone&&P.createElement("div",{className:"lk-button-group"},P.createElement(tO,{source:j.Source.Microphone,showIcon:!0,onChange:b,onDeviceError:T=>n==null?void 0:n({source:j.Source.Microphone,error:T})},P.createElement($b,{trackRef:h,barCount:7,options:{minHeight:5}})),P.createElement("div",{className:"lk-button-group-menu"},P.createElement(dO,{kind:"audioinput",onActiveDeviceChange:(T,C)=>y(C??"default")}))),o.leave&&P.createElement(Wb,null,"Disconnect"),P.createElement($w,null))}function hO(){return{url:"##livekit-url-placeholder##",token:"##livekit-token-placeholder##"}}const mO=a=>Ne.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...a,children:[Ne.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M2 2.75A2.75 2.75 0 0 1 4.75 0h6.5A2.75 2.75 0 0 1 14 2.75v10.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-.5a.75.75 0 0 1 1.5 0v.5c0 .69.56 1.25 1.25 1.25h6.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25h-6.5c-.69 0-1.25.56-1.25 1.25v.5a.75.75 0 0 1-1.5 0v-.5Z",clipRule:"evenodd"}),Ne.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M8.78 7.47a.75.75 0 0 1 0 1.06l-2.25 2.25a.75.75 0 1 1-1.06-1.06l.97-.97H1.75a.75.75 0 0 1 0-1.5h4.69l-.97-.97a.75.75 0 0 1 1.06-1.06l2.25 2.25Z",clipRule:"evenodd"})]}),pO=({onDisconnect:a})=>{const e=sh(),{canPlayAudio:n}=Jb({props:{}}),{state:r,audioTrack:o}=Yw();return Ne.jsxs("div",{className:"content",children:[Ne.jsxs("header",{className:"header",children:[Ne.jsxs("div",{className:"header-left",children:[Ne.jsx("h2",{children:"livekit-rtc"}),Ne.jsx("span",{className:`connection-state ${["connecting","disconnected"].includes(e)?"state-inactive":""}`,children:e})]}),Ne.jsx("div",{className:"header-controls",children:Ne.jsxs(Wb,{onClick:a,children:[Ne.jsx(mO,{}),"Disconnect"]})})]}),Ne.jsxs("div",{className:"controls",children:[Ne.jsx(fO,{controls:{microphone:!0,leave:!1}}),n&&e==Te.Connected&&r!=="connecting"&&Ne.jsx("div",{className:"agent-visualizer",children:Ne.jsx($b,{state:r,barCount:15,trackRef:o,options:{minHeight:15,maxHeight:30}})})]})]})},gO=()=>{const[a,e]=P.useState(null),[n,r]=P.useState(!0),o=hO();return a?Ne.jsxs("div",{children:["Error: ",a]}):n?Ne.jsxs(_w,{serverUrl:o.url,token:o.token,onError:l=>e(l.message),children:[Ne.jsx(pO,{onDisconnect:()=>r(!1)}),Ne.jsx(sO,{})]}):Ne.jsx("div",{className:"content",children:Ne.jsxs("header",{className:"header",children:[Ne.jsxs("div",{className:"header-left",children:[Ne.jsx("h2",{children:"livekit-rtc"}),Ne.jsx("span",{className:"state-inactive",children:"disconnected"})]}),Ne.jsx("div",{className:"header-controls",children:Ne.jsx("span",{className:"state-inactive",children:"Re-run the cell to connect"})})]})})};Mk.createRoot(document.getElementById("root")).render(Ne.jsx(P.StrictMode,{children:Ne.jsx(gO,{})}));</script>
    <style rel="stylesheet" crossorigin>[data-lk-theme=default]{color-scheme:dark;--lk-bg: #111;--lk-bg2: #1e1e1e;--lk-bg3: #2b2b2b;--lk-bg4: #373737;--lk-bg5: #444444;--lk-fg: #fff;--lk-fg2: whitesmoke;--lk-fg3: #ebebeb;--lk-fg4: #e0e0e0;--lk-fg5: #d6d6d6;--lk-border-color: rgba(255, 255, 255, .1);--lk-accent-fg: #fff;--lk-accent-bg: #1f8cf9;--lk-accent2: #3396fa;--lk-accent3: #47a0fa;--lk-accent4: #5babfb;--lk-danger-fg: #fff;--lk-danger: #f91f31;--lk-danger2: #fa3343;--lk-danger3: #fa4756;--lk-danger4: #fb5b68;--lk-success-fg: #fff;--lk-success: #1ff968;--lk-success2: #33fa75;--lk-success3: #47fa83;--lk-success4: #5bfb90;--lk-control-fg: var(--lk-fg);--lk-control-bg: var(--lk-bg2);--lk-control-hover-bg: var(--lk-bg3);--lk-control-active-bg: var(--lk-bg4);--lk-control-active-hover-bg: var(--lk-bg5);--lk-connection-excellent: #06db4d;--lk-connection-good: #f9b11f;--lk-connection-poor: #f91f31;--lk-font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";--lk-font-size: 16px;--lk-line-height: 1.5;--lk-border-radius: .5rem;--lk-box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .15);--lk-drop-shadow: rgba(255, 255, 255, .2) 0px 0px 24px;--lk-grid-gap: .5rem;--lk-control-bar-height: 69px;--lk-chat-header-height: 69px}.lk-button,.lk-start-audio-button,.lk-chat-toggle,.lk-disconnect-button{position:relative;display:inline-flex;align-items:center;justify-content:center;gap:.5rem;padding:.625rem 1rem;color:var(--lk-control-fg);background-image:none;background-color:var(--lk-control-bg);border:0;border-radius:var(--lk-border-radius);cursor:pointer;white-space:nowrap}.lk-button:not(:disabled):hover,.lk-start-audio-button:not(:disabled):hover,.lk-chat-toggle:not(:disabled):hover,.lk-disconnect-button:not(:disabled):hover{background-color:var(--lk-control-hover-bg)}.lk-button>svg,.lk-start-audio-button>svg,.lk-chat-toggle>svg,.lk-disconnect-button>svg{overflow:visible}.lk-button[aria-pressed=true],[aria-pressed=true].lk-start-audio-button,[aria-pressed=true].lk-chat-toggle,[aria-pressed=true].lk-disconnect-button{background-color:var(--lk-control-active-bg)}.lk-button[aria-pressed=true]:hover,[aria-pressed=true].lk-start-audio-button:hover,[aria-pressed=true].lk-chat-toggle:hover,[aria-pressed=true].lk-disconnect-button:hover{background-color:var(--lk-control-active-hover-bg)}.lk-button[data-lk-source=screen_share][data-lk-enabled=true],[data-lk-source=screen_share][data-lk-enabled=true].lk-start-audio-button,[data-lk-source=screen_share][data-lk-enabled=true].lk-chat-toggle,[data-lk-source=screen_share][data-lk-enabled=true].lk-disconnect-button{background-color:var(--lk-accent-bg)}.lk-button[data-lk-source=screen_share][data-lk-enabled=true]:hover,[data-lk-source=screen_share][data-lk-enabled=true].lk-start-audio-button:hover,[data-lk-source=screen_share][data-lk-enabled=true].lk-chat-toggle:hover,[data-lk-source=screen_share][data-lk-enabled=true].lk-disconnect-button:hover{background-color:var(--lk-accent2)}.lk-button:disabled,.lk-start-audio-button:disabled,.lk-chat-toggle:disabled,.lk-disconnect-button:disabled{opacity:.5}.lk-button-group{display:inline-flex;align-items:stretch;height:100%}.lk-button-group>.lk-button:first-child,.lk-button-group>.lk-start-audio-button:first-child,.lk-button-group>.lk-chat-toggle:first-child,.lk-button-group>.lk-disconnect-button:first-child{border-top-right-radius:0;border-bottom-right-radius:0}.lk-button-group-menu{position:relative;flex-shrink:0}.lk-button-group-menu>.lk-button,.lk-button-group-menu>.lk-start-audio-button,.lk-button-group-menu>.lk-chat-toggle,.lk-button-group-menu>.lk-disconnect-button{height:100%;border-top-left-radius:0;border-bottom-left-radius:0}.lk-button-group-menu>.lk-button:after,.lk-button-group-menu>.lk-start-audio-button:after,.lk-button-group-menu>.lk-chat-toggle:after,.lk-button-group-menu>.lk-disconnect-button:after{margin-left:0}.lk-button-menu:after{display:inline-block;content:"";width:.5em;height:.5em;margin-top:-.25rem;margin-left:.5rem;border-left:.125em solid;border-bottom:.125em solid;transform:rotate(-45deg);transform-origin:center center}.lk-disconnect-button{font-weight:600;color:var(--lk-danger);border:1px solid var(--lk-danger)}.lk-disconnect-button:not(:disabled):hover{--lk-control-hover-bg: var(--lk-danger2);color:var(--lk-danger-fg)}.lk-disconnect-button:not(:disabled):active{--lk-control-hover-bg: var(--lk-danger3);color:var(--lk-danger-fg)}.lk-chat-toggle{position:relative}.lk-chat-toggle[data-lk-unread-msgs]:not([data-lk-unread-msgs="0"]):after{content:attr(data-lk-unread-msgs);position:absolute;top:0;left:0;padding:.25rem;margin-left:.25rem;margin-top:.25rem;border-radius:50%;font-size:.5rem;line-height:.75;background:var(--lk-accent-bg)}.lk-media-device-select:not(:last-child){padding-bottom:.5rem;margin-bottom:.75rem;border-bottom:1px solid var(--lk-border-color)}.lk-media-device-select li:not(:last-child){margin-bottom:.25rem}.lk-media-device-select li>.lk-button{width:100%;justify-content:start;padding-block:.5rem}.lk-media-device-select li:not([data-lk-active=true])>.lk-button:not(:disabled):hover{background-color:var(--lk-bg3)}.lk-media-device-select [data-lk-active=false]>.lk-button:hover{cursor:pointer;background-color:#0000000d}.lk-media-device-select [data-lk-active=true]>.lk-button{color:var(--lk-accent-fg);background-color:var(--lk-accent-bg)}.lk-device-menu{width:max-content;position:absolute;top:0;left:0;z-index:5;min-width:10rem;padding:.5rem;margin-bottom:.25rem;white-space:nowrap;background-color:var(--lk-bg2);border:1px solid var(--lk-border-color);border-radius:.75rem;box-shadow:var(--lk-box-shadow)}.lk-device-menu-heading{padding:.25rem .5rem;font-weight:700;opacity:.65}.lk-start-audio-button{color:var(--lk-accent-fg);background-color:var(--lk-accent-bg)}@media screen and (max-width: 600px){.lk-start-audio-button{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%)}}.lk-pagination-control{position:absolute;bottom:1rem;left:50%;transform:translate(-50%);display:flex;align-items:stretch;background-color:var(--lk-control-bg);border-radius:var(--lk-border-radius);transition:opacity ease-in-out .15s;opacity:0}.lk-pagination-control:hover{opacity:1}.lk-pagination-control>.lk-button:first-child{border-top-right-radius:0;border-bottom-right-radius:0}.lk-pagination-control>.lk-button:first-child>svg{transform:rotate(180deg)}.lk-pagination-control>.lk-button:last-child{border-top-left-radius:0;border-bottom-left-radius:0}.lk-pagination-count{padding:.5rem .875rem;border-inline:1px solid var(--lk-bg)}[data-lk-user-interaction=true].lk-pagination-control{opacity:1}.lk-pagination-indicator{position:absolute;height:var(--lk-grid-gap);background-color:var(--lk-bg2);width:fit-content;padding:.2rem .5rem;bottom:calc(var(--lk-grid-gap)/2);left:50%;transform:translate(-50%);border-radius:2rem;opacity:1;display:flex;gap:.2rem;align-items:center}.lk-pagination-indicator span{display:inline-block;width:.4rem;height:.4rem;border-radius:9999999px;background-color:var(--lk-fg);opacity:.35;transition:opacity linear .2s}.lk-pagination-indicator span[data-lk-active]{opacity:.9}.lk-grid-layout{--lk-col-count: 1;--lk-row-count: 1;display:grid;grid-template-columns:repeat(var(--lk-col-count),minmax(0,1fr));grid-auto-rows:minmax(0,1fr);grid-gap:var(--lk-grid-gap);width:100%;height:100%;max-width:100%;max-height:100%;padding:var(--lk-grid-gap)}.lk-grid-layout[data-lk-pagination=true]{padding-bottom:calc(var(--lk-grid-gap)*2)}.lk-focus-layout{display:grid;grid-template-columns:1fr 5fr;gap:var(--lk-grid-gap);width:100%;max-height:100%;padding:var(--lk-grid-gap)}.lk-focused-participant{position:relative}.lk-focused-participant .lk-pip-track{position:absolute;top:10px;right:10px;width:20%;height:auto}@media (max-width: 600px){.lk-focus-layout{grid-template-columns:1fr;grid-template-rows:5fr 1fr}.lk-carousel{order:1}}.lk-carousel{max-height:100%;display:flex;gap:var(--lk-grid-gap)}.lk-carousel>*{flex-shrink:0;aspect-ratio:16/10;scroll-snap-align:start}.lk-carousel[data-lk-orientation=vertical]{flex-direction:column;scroll-snap-type:y mandatory;overflow-y:auto;overflow-x:hidden}.lk-carousel[data-lk-orientation=vertical]>*{--lk-height-minus-gaps: calc(100% - calc(var(--lk-grid-gap) * calc(var(--lk-max-visible-tiles) - 1)));height:calc(var(--lk-height-minus-gaps)/var(--lk-max-visible-tiles))}.lk-carousel[data-lk-orientation=horizontal]{scroll-snap-type:x mandatory;overflow-y:hidden;overflow-x:auto}.lk-carousel[data-lk-orientation=horizontal]>*{--lk-width-minus-gaps: calc(100% - var(--lk-grid-gap) * (var(--lk-max-visible-tiles) - 1));width:calc(var(--lk-width-minus-gaps)/var(--lk-max-visible-tiles))}.lk-connection-quality{width:1.5rem;height:1.5rem}.lk-track-muted-indicator-camera,.lk-track-muted-indicator-microphone{position:relative;width:var(--lk-indicator-size, 1rem);height:var(--lk-indicator-size, 1rem);margin-inline-end:.25rem;transition:opacity .25s ease-in-out}.lk-track-muted-indicator-camera[data-lk-muted=true]{opacity:.5}.lk-track-muted-indicator-microphone{--lk-bg: var(--lk-icon-mic)}.lk-track-muted-indicator-microphone[data-lk-muted=true]{opacity:.5}.lk-participant-name{font-size:.875rem}.lk-participant-media-video{width:100%;height:100%;object-fit:cover;object-position:center;background-color:#000}.lk-participant-media-video[data-lk-orientation=landscape]{object-fit:cover}.lk-participant-media-video[data-lk-orientation=portrait],.lk-participant-media-video[data-lk-source=screen_share]{object-fit:contain;background-color:var(--lk-bg2)}.lk-participant-media-audio{width:auto}[data-lk-facing-mode=user] .lk-participant-media-video[data-lk-local-participant=true][data-lk-source=camera]{transform:rotateY(180deg)}.lk-audio-visualizer{width:100%;height:100%;min-height:160px;background:var(--lk-bg-control);aspect-ratio:16/9;border-radius:.5rem;display:flex;justify-content:space-around;align-items:center}.lk-audio-visualizer>rect{fill:var(--lk-accent-bg);transition:transform .1s cubic-bezier(.19,.02,.09,1)}.lk-audio-visualizer>path{stroke:var(--lk-accent-bg);transition:.1s cubic-bezier(.19,.02,.09,1)}.lk-audio-bar-visualizer{display:flex;align-items:center;justify-content:center;width:100%;height:100%;background:var(--lk-bg);gap:var(--lk-va-bar-gap, 24px)}.lk-audio-bar-visualizer>.lk-audio-bar{transform-origin:"center";height:100%;width:var(--lk-va-bar-width, 12px);border-radius:var(--lk-va-bar-border-radius, 32px);background-color:var(--lk-va-bar-bg, rgba(136, 136, 136, .2));transition:background-color .25s ease-out}.lk-audio-bar-visualizer[data-lk-va-state=speaking]>.lk-audio-bar,.lk-audio-bar-visualizer>.lk-audio-bar.lk-highlighted,.lk-audio-bar-visualizer>[data-lk-highlighted=true]{background-color:var(--lk-fg, rgb(136, 136, 136));transition:none}.lk-audio-bar-visualizer[data-lk-va-state=thinking]{transition:background-color .15s ease-out}.lk-participant-tile{--lk-speaking-indicator-width: 2.5px;position:relative;display:flex;flex-direction:column;gap:.375rem;overflow:hidden;border-radius:var(--lk-border-radius)}.lk-participant-tile:after{content:"";position:absolute;top:0;bottom:0;left:0;right:0;border-radius:var(--lk-border-radius);border:0px solid var(--lk-accent-bg);transition-property:border opacity;transition-delay:.5s;transition-duration:.4s;pointer-events:none}.lk-participant-tile[data-lk-speaking=true]:not([data-lk-source=screen_share]):after{transition-delay:0s;transition-duration:.2s;border-width:var(--lk-speaking-indicator-width)}.lk-participant-tile .lk-focus-toggle-button{position:absolute;top:.25rem;right:.25rem;padding:.25rem;background-color:#00000080;border-radius:calc(var(--lk-border-radius)/2);opacity:0;transition:opacity .2s ease-in-out;transition-delay:.2s}.lk-participant-tile:hover .lk-focus-toggle-button,.lk-participant-tile:focus .lk-focus-toggle-button{opacity:1;transition-delay:0}.lk-participant-tile .lk-connection-quality{opacity:0;transition:opacity .2s ease-in-out;transition-delay:.2s}.lk-participant-tile .lk-connection-quality[data-lk-quality=poor]{opacity:1;transition-delay:0}.lk-participant-tile:hover .lk-connection-quality,.lk-participant-tile:focus .lk-connection-quality{opacity:1;transition-delay:0}.lk-participant-tile .lk-participant-placeholder{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;align-items:center;justify-content:center;background-color:var(--lk-bg2);opacity:0;transition:opacity .2s ease-in-out;pointer-events:none;border-radius:var(--lk-border-radius)}.lk-participant-tile .lk-participant-placeholder svg{height:100%;width:auto;padding:10%}.lk-participant-tile[data-lk-video-muted=true][data-lk-source=camera] .lk-participant-placeholder{opacity:1}.lk-participant-metadata{position:absolute;right:.25rem;bottom:.25rem;left:.25rem;display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:.5rem;line-height:1}.lk-participant-metadata-item{display:flex;align-items:center;padding:.25rem;background-color:#00000080;border-radius:calc(var(--lk-border-radius)/2)}.lk-toast{position:fixed;top:.75rem;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:.5rem;padding:.75rem 1.25rem;background-color:var(--lk-bg);border:1px solid var(--lk-border-color);border-radius:var(--lk-border-radius);box-shadow:var(--lk-box-shadow)}.lk-spinner{animation:lk-rotate 2s infinite linear}@keyframes lk-rotate{0%{transform:rotate(0)}to{transform:rotate(359deg)}}.lk-room-container{background-color:var(--lk-bg);line-height:var(--lk-line-height)}.lk-room-container{position:relative;width:100%;height:100%;--lk-has-imported-styles: "true"}.lk-room-container *[class^=lk-],.lk-room-container *[class*=" lk-"]{box-sizing:border-box}.lk-audio-conference{position:relative;width:100%;height:100%}.lk-audio-conference-stage{width:100%;height:100%;display:grid;grid-template-columns:repeat(3,1fr);gap:10px}.lk-chat{display:grid;grid-template-rows:var(--lk-chat-header-height) 1fr var(--lk-control-bar-height);width:clamp(200px,55ch,60ch);background-color:var(--lk-bg2);border-left:1px solid var(--lk-border-color);align-items:end}.lk-chat-header{height:var(--lk-chat-header-height);padding:.75rem;position:relative;display:flex;align-items:center;justify-content:center}.lk-chat-header .lk-close-button{position:absolute;right:0;transform:translate(-50%);background-color:#0000}.lk-chat-header .lk-close-button:hover{background-color:var(--lk-control-active-hover-bg)}.lk-chat-messages{display:flex;width:100%;max-height:100%;flex-direction:column;gap:.25rem;overflow:auto}.lk-chat-entry{display:flex;flex-direction:column;gap:.25rem;margin:0 .25rem}.lk-chat-entry .lk-meta-data{font-size:.75rem;color:var(--lk-fg5);white-space:nowrap;padding:0 .3rem;display:flex}.lk-chat-entry .lk-meta-data .lk-participant-name{margin-top:1rem}.lk-chat-entry .lk-meta-data .lk-timestamp{margin-left:auto;align-self:flex-end}.lk-chat-entry .lk-edit-button{background:none;float:right;margin:0;padding:0 .25rem;border-radius:0;font-size:12px}.lk-chat-entry .lk-message-body{display:inline-block;border-radius:15px;padding:.25rem .75rem;word-break:break-word;width:fit-content;max-width:calc(100% - 32px)}.lk-chat-entry[data-lk-message-origin=local] .lk-message-body{background-color:var(--lk-bg5)}.lk-chat-entry[data-lk-message-origin=remote] .lk-message-body{background-color:var(--lk-accent4)}.lk-chat-entry a{text-decoration:underline;color:inherit}.lk-chat-entry:last-child{margin-bottom:.25rem}.lk-chat-form{display:flex;gap:.75rem;padding:.75rem;border-top:1px solid var(--lk-border-color);max-height:var(--lk-control-bar-height)}.lk-chat-form-input{width:100%}@media (max-width: 600px){.lk-chat{position:fixed;top:0;right:0;max-width:100%;bottom:var(--lk-control-bar-height)}}.lk-control-bar,.lk-agent-control-bar{display:flex;gap:.5rem;align-items:center;justify-content:center;padding:.75rem;border-top:1px solid var(--lk-border-color);max-height:var(--lk-control-bar-height)}.lk-agent-control-bar{height:var(--lk-control-bar-height);--lk-bg: transparent;--lk-va-bar-width: 2px;--lk-va-bar-gap: 4px;--lk-va-bar-border-radius: 1px}.lk-agent-control-bar .lk-audio-bar-visualizer .lk-audio-bar.lk-highlighted{filter:none}.lk-prejoin{background-color:var(--lk-bg);line-height:var(--lk-line-height)}[data-lk-theme]{font-size:var(--lk-font-size);font-family:var(--lk-font-family);color:var(--lk-fg)}[data-lk-theme] button,[data-lk-theme] input{font:inherit;line-height:inherit}[data-lk-theme] .lk-button{-webkit-user-select:none;user-select:none}[data-lk-theme] .lk-list{list-style:none;margin:0;padding:0}[data-lk-theme] .lk-form-control{font-family:var(--lk-font-family);padding:.625rem 1rem;background-color:var(--lk-control-bg);border:1px solid var(--lk-border-color);border-radius:var(--lk-border-radius)}.lk-prejoin{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;padding:1rem;gap:1rem;margin-inline:auto;background-color:var(--lk-bg);width:min(100%,480px);align-items:stretch}.lk-prejoin .lk-video-container{position:relative;width:100%;height:auto;aspect-ratio:16/10;background-color:#000;border-radius:var(--lk-border-radius);overflow:hidden}.lk-prejoin .lk-video-container video,.lk-prejoin .lk-video-container .lk-camera-off-note{display:block;width:100%;height:100%;object-fit:cover}.lk-prejoin .lk-video-container video[data-lk-facing-mode=user]{transform:rotateY(180deg)}.lk-prejoin .lk-video-container .lk-camera-off-note{position:absolute;top:0;left:0;width:100%;aspect-ratio:16/10;background-color:#000;display:grid;place-items:center}.lk-prejoin .lk-video-container .lk-camera-off-note>*{height:70%;max-width:100%}.lk-prejoin .lk-audio-container{display:none}.lk-prejoin .lk-audio-container audio{width:100%;height:auto}.lk-prejoin .lk-button-group-container{display:flex;flex-wrap:nowrap;gap:1rem}.lk-prejoin .lk-button-group-container>.lk-button-group{width:50%}.lk-prejoin .lk-button-group-container>.lk-button-group>.lk-button{justify-content:left}.lk-prejoin .lk-button-group-container>.lk-button-group>.lk-button:first-child{width:100%}@media (max-width: 400px){.lk-prejoin .lk-button-group-container{flex-wrap:wrap}.lk-prejoin .lk-button-group-container>.lk-button-group{width:100%}}.lk-prejoin .lk-username-container{display:flex;flex-direction:column;gap:1rem;width:100%;max-width:100%}.lk-prejoin .lk-join-button{--lk-control-fg: var(--lk-accent-fg);--lk-control-bg: var(--lk-accent-bg);--lk-control-hover-bg: var(--lk-accent2);--lk-control-active-bg: var(--lk-accent3);--lk-control-active-hover-bg: var(--lk-accent4);background-color:var(--lk-control-bg)}.lk-prejoin .lk-join-button:hover{background-color:var(--lk-control-hover-bg)}.lk-focus-layout-wrapper,.lk-grid-layout-wrapper{position:relative;display:flex;justify-content:center;width:100%;height:calc(100% - var(--lk-control-bar-height))}.lk-grid-layout-wrapper{flex-direction:column;align-items:center}.lk-focus-layout-wrapper{align-items:stretch}.lk-video-conference{position:relative;display:flex;align-items:stretch;height:100%}.lk-video-conference-inner{display:flex;flex-direction:column;align-items:stretch;width:100%}.lk-settings-menu-modal{position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:var(--lk-bg);padding:1rem;display:flex;flex-direction:column;align-items:center;gap:.5rem;padding:.75rem 1.25rem;background-color:var(--lk-bg);border:1px solid var(--lk-border-color);border-radius:var(--lk-border-radius);box-shadow:var(--lk-box-shadow);min-width:50vw;min-height:50vh}:root{--lk-fg: #111;--lk-fg-secondary: #333;--lk-fg-tertiary: #555;--lk-bg: #fff;--lk-bg-secondary: #f5f5f5;--lk-bg-tertiary: #fafafa;--lk-accent-fg: #fff;--lk-accent-bg: #1f8cf9;--lk-danger-fg: #fff;--lk-danger: #f91f31;--lk-danger-text: #6d0311;--lk-danger-bg: #fecdd4;--lk-success-fg: #fff;--lk-success: #1ff968;--lk-success-text: #036d26;--lk-success-bg: #cdfedd;--lk-control-fg: var(--fg);--lk-control-bg: var(--bg-secondary);--lk-connection-excellent: #06db4d;--lk-connection-good: #f9b11f;--lk-connection-poor: #f91f31;--lk-va-bar-gap: 8px;--lk-va-bar-width: 8px}.lk-disconnect-button{border:unset;color:unset;font-weight:unset;font-size:.8em}.lk-agent-control-bar{width:100%;justify-content:space-between}@media screen and (max-width: 600px){.lk-start-audio-button{position:unset;top:unset;left:unset;transform:unset}}.lk-start-audio-button{color:#000;background-color:#dadada}.app-container{max-width:800px;margin:0 auto;padding:10px}.content{width:100%;max-width:100%;overflow-x:hidden;padding:0;margin:0}.header{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;height:32px;border-bottom:1px solid #eee;padding-bottom:8px;width:100%}.header-left{display:flex;align-items:center;gap:10px}.header h2{margin:0;font-size:1em;font-weight:400;color:#444}.header-controls{display:flex;align-items:center;gap:15px}.connection-state,.state-inactive{font-size:.85em;margin:0;padding:0}.connection-state{color:#06c}.state-inactive{color:#999}.controls{display:flex;flex-direction:row;justify-content:space-between}.agent-visualizer{display:flex;flex-direction:row;width:25%;margin-right:32px;height:var(--lk-control-bar-height)}</style>
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>
